Skip to content
Advertisement

How to redirect from google drive in laravel

I’m using google drive in my project for login with google.

It’s working fine for me, but the problem is when user select email, in callback method user have to redirect to '/', but user will redirect to home, this is callback method :

JavaScript

It’s ok for next time user login with google, but for the first time redirect to home.

And in loggedIn function for the first time returned false because two_factor_type is off in default :

JavaScript

Even in my LoginController or RegisterController i changed this :

JavaScript

To this :

JavaScript

So why it will redirect to home ?

Advertisement

Answer

in app/Http/Controllers/Auth/LoginController check if the controller protected with middleware, e.g:

JavaScript

in app/Http/Middleware/RedirectIfAuthenticated will check if current auth()->user() is authenticated

change the default code to :

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement