[Yii2-Authclient] How to redirect to previous URL after login

  • A guest is reading page A.

  • He click on "login with facebook" button

-> After user logined how to redirect him back to page A

Somebody help me thanks !

use this:


return $this->goBack();

It will be easy like that if logon process was not throw over facebook

see this module may be help you.

User Module

Can you tell me more detail? I can’t find any flow like my problem from your link

I just tell you about it, see it controllers, maybe find solution of your problem :)

or you can use it

Using OAuth2 for logging-in presents some problems. Although you can have multiple “return urls” registered with Facebook, that doesn’t scale if you have loads of pages on your site.

The other option is that you put some information into session when the user clicks the login button, including the page they are on. When you return from FB to your return URL, check if that session entry exists and if it does, redirect and then clear the session entry.

You can alternatively pass a "state" value to most OAuth2 providers, which is returned to the return url. That parameter could potentially be used to know what page to go back to (or used as a key for session data you stored earlier).

Thanks

I’ll try it