简体   繁体   中英

Redirecting back to web page after User has clicked cancel

I integrated facebook login through laravel/socialite and its working fine.

The problem is when user clicks cancel in the popup from facebook, the screen will stayed on facebook's page itself instead of redirecting to my site.

Is anywhere i need to specify the cancel redirecting url in facebook login app? I don't know how to handle this redirection.

Just found out the answer here

Just for other who are wondering, I just figured out a way... In SocialAuthController: use Illuminate\\Http\\Request;

Then make constructor as:

 protected $request; public function __construct (Request $request) { $this->request = $request; } 

and then in callback() function:

 if (isset($this->request['error'])) { return redirect()->to('/error'); //make your error route or do whatever you want!! } else { // this is my code, your actual code will go here on success print_r($service); $service = new SocialAccountService(); $user = $service->createOrGetUser(Socialite::driver($provider)); $providerUser = \\Socialite::driver('facebook')->user(); print_r($providerUser); auth()->login($user); return redirect()->to('/home'); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM