In my UserProvider i want to check if the user that is in the session is still valid. Valid means, its access token (fetched from an external SSO provider) is not expired and valid in terms of signature.
I find the refreshUser()
method an appropriate place for this check, since I want to know on every request if it is still valid.
I notice that I have three return possibilities for the method:
- Return the user -> means the user is still allowed to be logged in
- Throw a
UserNameNotFoundException
for "The user does not exist anymore" - Throw a
UnsupportedUserException
for "This user provider does not support the user, try the next one"
I think, option 2. is the required one when the user expired.
But I also need to log out the user in this case from the SSO, so I have to redirect him to the logout page from the SSO provider.
How can I redirect the user, after the user from the refreshUser()
method was invalidated?
At the moment symfony just return and the user is logged out in symfony.
Are there any events to work with?