diff --git a/src/Titano.Server/Api/UserEndpoints.cs b/src/Titano.Server/Api/UserEndpoints.cs index 2a4099fc..7e11fcfb 100644 --- a/src/Titano.Server/Api/UserEndpoints.cs +++ b/src/Titano.Server/Api/UserEndpoints.cs @@ -119,6 +119,8 @@ public static class UserEndpoints private static async Task 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);