fix(server): refuse a password reset of the caller's own account
A reset revokes every token of the account, so resetting oneself ended the admin session before the temporary password could be read. Own passwords change through /auth/password. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
1 file changed
+2
@@ -119,6 +119,8 @@ public static class UserEndpoints
|
||||
private static async Task<IResult> ResetPasswordAsync(HttpContext context, Caller caller, Guid id, ResetPasswordRequest? request, TitanoDatabase db, AuditLog audit)
|
||||
{
|
||||
var ct = context.RequestAborted;
|
||||
// A reset ends every session of the account, the caller's too, before the temporary password could be read.
|
||||
if (id == caller.Id) return ApiErrors.Conflict(context, "self");
|
||||
if (await db.Users.GetAsync(id, ct) is not { } user) return ApiErrors.NotFound(context, "user");
|
||||
var password = string.IsNullOrEmpty(request?.Password) ? TemporaryPassword.Generate() : request.Password;
|
||||
if (!PasswordHasher.IsAcceptable(password)) return WeakPassword(context);
|
||||
|
||||
Reference in new issue
Block a user