Skip to content

Change redirect when authenticated #3564

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

Merged
merged 1 commit into from
Nov 21, 2015
Merged

Change redirect when authenticated #3564

merged 1 commit into from
Nov 21, 2015

Conversation

martinbean
Copy link
Contributor

The route /home doesn’t exist in a default Laravel application, whereas / does.

The route /home doesn’t exist in a default Laravel application, whereas / does.
@surfer190
Copy link

If you check the docs, you can put this in the AuthController:

protected $redirectPath = '/dashboard';

that will change the location after a successful login (The default being /home).
However, it doesn't actually use this $redirectPath value. It is hard-coded to /home:

public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            return redirect('/home');
        }

        return $next($request);
    }

@arcanedev-maroc
Copy link
Contributor

👍 for @martinbean.

@martinbean
Copy link
Contributor Author

@surfer190 I know this, but in a new, clean Laravel installation, the route /home doesn’t exist, therefore it doesn’t make sense to redirect there if authenticated.

@pishguy
Copy link

pishguy commented Nov 20, 2015

💯 for @martinbean

@RomainLanz
Copy link

👍

I do that every time I begin a new project.

@mydnic
Copy link

mydnic commented Nov 20, 2015

👍

@surfer190
Copy link

Yes but that is the point...you need to create the home route. Laravel assumes that the authenticated home screen, is different from the public root of the site. That is why $redirectPath exists, so you can easily override that path. But that does not work...

On 20 Nov 2015, at 12:35 PM, Martin Bean notifications@github.com wrote:

@surfer190 I know this, but in a new, clean Laravel installation, the route /home doesn’t exist, therefore it doesn’t make sense to redirect there on successful authentication.


Reply to this email directly or view it on GitHub.

@shawnlindstrom
Copy link

It's a built in penalty (I would call it a feature honestly) for not RTFM at: http://laravel.com/docs/5.1/authentication#included-authenticating

When you forget on a new project it's really easy to identify the issue because you get immediate, obvious feedback. If you are new to Laravel, the docs or a very simple Google search of 'laravel redirect home on login' will straighten you out quickly.

The suggested change wouldn't provide any immediate feedback which would actually be more confusing. Additionally, some will want the redirect to / others will want something else. Most, if not all, will not route to /home on login.

taylorotwell added a commit that referenced this pull request Nov 21, 2015
Change redirect when authenticated
@taylorotwell taylorotwell merged commit 091489d into laravel:master Nov 21, 2015
@martinbean martinbean deleted the patch-1 branch November 21, 2015 19:01
@martinbean
Copy link
Contributor Author

🎉

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.

8 participants