Passport: Passport doesn't redirect back to authorization form after login

Created on 25 Jan 2017  路  11Comments  路  Source: laravel/passport

My flow:

  1. Unauthorized user clicks on the "Login via MyService" button on client.tld
  2. User is redirected to the authorization form on myservice.tld/oauth/authorize?client_id=...
  3. As the user is not logged in, he's redirected to myservice.tld/login
  4. User logs in
  5. User is redirected to myservice.tld

The problem:

How do I make the user to be redirected back to step 2 after step 4? So that he sees the authorization form immediately after logging in? Like that:

...

  1. User logs in
  2. User is redirected to the authorization form
  3. User presses 'Allow' or 'Deny' button
  4. User is redirected back to client.tld/login/MyService/calback...

I'm using passport v1.0.17. In my login controller I'm using something like this:

public function proceed()
{
    return redirect()->intended('/');
}

Most helpful comment

I had this very same issue while trying Passport with Laravel 8 and Breeze.

Fixed by changing the store(LoginRequest $request) function in AuthenticatedSessionController to return

return redirect()->intended(RouteServiceProvider::HOME)

I also made the same change in the RedirectIfAuthenticated.

This seems more like a Breeze issue/enhancement by the way, but figured it could help someone else if I posted this here.

All 11 comments

Did you manage to find more information on this? I am having the same issue. Does one have to write his own integration?

Nope :pensive:

I cannot even determine which step inside the app breaks that normal flow. Hope someone from contributors will clarify.

UPD: Weird thing, seems like everything works fine in mobile Safari and mobile Chrome, but not on any desktop browser :thinking:

Closing for lack of activity, hope you got the help you needed :)

Nope, then I would have closed this issue myself. This issue is still actual.

same here 6 months later. whenever one of my users wants to log into a socialite site they get redirected to the main site that uses passport but if they aint logged into the main site they get sent to the login page but once they login they stay on the main site. like to be able to redirect them back to the passport oauth page once they log in.
Can do @if(request()->has('authurl')) where authurl would be the authorization url from socialite then can redirect back to that by putting authurl in a hidden input field.

I have this same issue. Problem only on chrome(tested from 64-67).
If I enter through the link directly in the new tab, the problem does not occur, but if it is in the same card, laravel gets an invalid url()->previous()

Any updates on this one?

Hi, I just solve the problem and provide the gist below:

Fixed problem Laravel Passport doesn't redirect back to authorization form after login

I hope it helps you all.

@satyakresna, cool :+1:. @themsaid please pay attention

I had this very same issue while trying Passport with Laravel 8 and Breeze.

Fixed by changing the store(LoginRequest $request) function in AuthenticatedSessionController to return

return redirect()->intended(RouteServiceProvider::HOME)

I also made the same change in the RedirectIfAuthenticated.

This seems more like a Breeze issue/enhancement by the way, but figured it could help someone else if I posted this here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarkVilludo picture MarkVilludo  路  3Comments

soubhikchatterjee picture soubhikchatterjee  路  4Comments

SwiTool picture SwiTool  路  3Comments

huiyonghkw picture huiyonghkw  路  3Comments

Adesubomi picture Adesubomi  路  4Comments