laravel socialite doesnt take GET parameter to redirect on same page

坚强是说给别人听的谎言 提交于 2020-01-14 03:29:06

问题


I have a problem with one Laravel plugin its called Socialite it allows my site users to loggin with facebook, twitter etc i need some help

the problem is that after login it redirects to index page and the page visitor initiated login login url /login?redirect=https://www... socialite doesnt take this GET parameter default laravel login works with this parameter, but not socialite

i think it doesnt support redirect, because callback URL is set static in config I cannot figure out how to modify it to take GET paramenter with customs URLs

class SocialAuthController extends Controller { public function redirect() {  return Socialite::driver('facebook')->redirect(); } public function callback(SocialAccountService $service) { $user = $service->createOrGetUser(Socialite::driver('facebook')->user()); auth()->login($user); return redirect()->to('/home'); } }

How can i put a dynamic link to this intead of /home SO that it redirects me to the same page where i was before log-in. redirect()->to('/home')

Laravel Socialite plugin after login with Facebook or Twitter redirects to:

SocialAuthController.php ... public function callback(SocialAccountService $service, $provider) .... return redirect()->to('/');

I want to redirect visitor to page where login was initiated and not static page '/'

My login page receives GET parameter /login?redirect=http://www.website.com/dynamic_url

Please make code changes that Socialite plugin redirects after login to dynamically set redirect URL.


回答1:


It is really easy.I search it by myself.No one replied me so i think it was really embarrisng.

So the solution is return Redirect::to(URL::previous());



来源:https://stackoverflow.com/questions/39425687/laravel-socialite-doesnt-take-get-parameter-to-redirect-on-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!