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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user