feat(clerk-js): Role change session revocation #6815
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR ensures that when a user’s role is updated in the dashboard, all active sessions for that user are automatically revoked.
Previously, role changes did not revoke live sessions, which caused stale permission data to remain cached in active sessions. This led to UI inconsistencies and, more critically, potential security issues — for example, a downgraded user could still retain elevated access until their session expired.
By revoking all sessions immediately upon role change:
🚫 Eliminates cache bugs caused by outdated role/permission data.
🔒 Ensures that security updates take effect instantly across all devices.
🎛️ Preserves existing error handling and UI feedback patterns, with added visual indication during the revocation process.
How to Test
Assign a role to a user.
Log in with that user on multiple devices/tabs.
Change the user’s role in the dashboard.
Verify that all existing sessions are revoked and the user is prompted to log in again.
Confirm that the new role/permissions are applied correctly after reauthentication.