Search code examples
phplaravel-5laravel-socialite

laravel socialite error when user cancels


I'm creating a laravel 5 app, that has social authentication inbound, now I have all the code to get the user, register it or log in in case the user exists, all works fine. The issue is when the user does not agreed to login with the social provider into my app(eg, press the cancel button), somebody knows how to handle that.

Now if I press the cancel button on the social login window then it throws a 400 Client error.

Thanks in advance


Solution

  • You can use try-catch. Move all your login/registration code inside try block & inside catch block, redirect user to login page & show appropriate message