Hassaan
Hassaan

Reputation: 328

laravel socialite doesnt take GET parameter to redirect on same page

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 ogin 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.

Upvotes: 1

Views: 1877

Answers (2)

Marinario Agalliu
Marinario Agalliu

Reputation: 1179

A more easy way to do that is just:

return redirect()->back();

Happy coding! :D

Upvotes: 0

Hassaan
Hassaan

Reputation: 328

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());

Upvotes: 1

Related Questions