You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be good to see what is the recommended way to reload user roles after login, this is very likely a common scenario that symfony developers would be looking for.
Scenario:
John logs in with ROLE_USER
Jane, the "Super Admin" - adds ROLE_ADMIN to Joe's account
John refreshes the page, and sees that he is an admin now (without a logout).
Scenario 2:
Jane logs in
Jane upgrades her account, ROLE_SUBSCRIBER
Jane has new roles on her account without a logout
Potential solution for scenario 1: have a custom isEqualTo on the user entity to not check getRoles() (so that it doesn't cause a logout due to the now default behaviour) AND set an onCoreController listener that re-authenticates with user that has the updated roles (triggered by comparing a property such as updatedAt or similar):
Potential solution for scenario 2: Post-upgrade of the account, in the same action, again re-authenticate using guard with the code as above (I've tested it and the new role will appear)
@ptrm04 thanks for reporting this. I agree with you and this doesn't look very UX-friendly. So, I've opened symfony/symfony#39763 to try to fix this in Symfony. That's why I'm closing this doc issue for now, hoping that this will be fixed without the need of any hack or change in our applications. Thanks!
Uh oh!
There was an error while loading. Please reload this page.
It'd be good to see what is the recommended way to reload user roles after login, this is very likely a common scenario that symfony developers would be looking for.
Scenario:
ROLE_USER
ROLE_ADMIN
to Joe's accountScenario 2:
ROLE_SUBSCRIBER
Potential solution for scenario 1: have a custom
isEqualTo
on the user entity to not checkgetRoles()
(so that it doesn't cause a logout due to the now default behaviour) AND set anonCoreController
listener that re-authenticates with user that has the updated roles (triggered by comparing a property such asupdatedAt
or similar):Potential solution for scenario 2: Post-upgrade of the account, in the same action, again re-authenticate using guard with the code as above (I've tested it and the new role will appear)
Page: https://github.com/symfony/symfony-docs/blob/5.x/security.rst
A real world example: Spotify is apparently made in Symfony, and after upgrading to Premium, they do not ask you to log back in.
Thanks,
Peter
The text was updated successfully, but these errors were encountered: