dimanche 7 octobre 2018

How to validate Google auth status with Laravel Socialite?

The users in my web app are logging in only using Google authentication. Now I need to log out users whenever they log out of the respective Google account.

My plan was to add a middleware that would check their session against google if a certain time has passed since last check. However I can't find a way to do the check in the middleware. Can I somehow ask google "Is this still user@example.com?"?

In the authentication controller \Socialite::driver('google')->user() gives me a google user that I could compare against the logged in user using email fields. However, in the midleware this just gives me an InvalidStateException. It seems that I'd have to redirect user to google first which I'm reluctant to do as I'm planning to do these checks every minute and checks should be as invisible as possible (unless user has logged out of google and will be logged out in the app as well).



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire