Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] add routes name to register and login paths #140

Merged
merged 1 commit into from
Feb 21, 2022
Merged

[1.x] add routes name to register and login paths #140

merged 1 commit into from
Feb 21, 2022

Conversation

alphaolomi
Copy link
Contributor

Versions

  • PHP 8.1.2
  • Laravel 9.1.0

file: app/Http/Middleware/Authenticate.php uses route helper with name login
This PR adds the route name login

<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware {
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('login');
        }
    }
}

Reproducing

laravel new laravel-api
cd laravel-api
php artisan breeze:install api
# setup db
php artisan migrate
php artisan serve
# visit http://localhost:8000/api/user
# see error Symfony\Component\Routing\Exception\RouteNotFoundException

@alphaolomi alphaolomi changed the title feat: add routes name to register and login paths [1.x] add routes name to register and login paths Feb 19, 2022
@emargareten
Copy link
Contributor

emargareten commented Feb 21, 2022

I think that this middleware should be removed in the api stack entirely and call the parent middleware in Http\Kernel.php.

@taylorotwell taylorotwell merged commit 26c31c3 into laravel:1.x Feb 21, 2022
slimani-dev pushed a commit to slimani-dev/breeze that referenced this pull request Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants