Rolwijziging beëindigt het lopende access token van de betrokken gebruiker (security stamp), refresh blijft werken

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 13:48:35 +01:00
co-authored by Claude Sonnet 5.5
parent 2f3f7fbb2f
commit 07bad14453
2 changed files with 91 additions and 0 deletions
@@ -258,7 +258,14 @@ public class UsersController : ControllerBase
await _userManager.AddToRoleAsync(target, request.NewRole);
if (targetRole != request.NewRole)
{
// A new security stamp ends the access tokens issued before the change (they carry the old role); the
// refresh token is deliberately left alone, so the client silently gets a new token with the new role.
// Only the stamp of the person whose role changed moves: everybody else, including the administrator
// who made the change, keeps their session.
await _userManager.UpdateSecurityStampAsync(target);
await _mail.SendRoleChangedAsync(target, request.NewRole, HttpContext.RequestAborted);
}
return Ok();
}