Question: Redirecting back to web page after User has clicked cancel

Question

Redirecting back to web page after User has clicked cancel

Answers 1
Added at 2016-12-30 11:12
Tags
Question

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.

Answers
nr: #1 dodano: 2016-12-30 11:12

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'); }

Source Show
◀ Wstecz