Skip to content

Commit

Permalink
Move audit to after username change
Browse files Browse the repository at this point in the history
  • Loading branch information
RiadGahlouz committed Dec 9, 2023
1 parent edd8110 commit 0158a73
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ public async Task<ActionResult> ChangeUsername(string oldUsername, string newUse
return Json(HttpStatusCode.BadRequest, "New username validation failed.", JsonRequestBehavior.AllowGet);
}


await _auditingService.SaveAuditRecordAsync(new UserAuditRecord(account, AuditedUserAction.ChangeUsername));

if (account.Username.Equals(newUsername, StringComparison.OrdinalIgnoreCase) == false)
{
// We're doing a full username change and not just a casing change so we need to lock the old username
Expand All @@ -142,6 +139,7 @@ public async Task<ActionResult> ChangeUsername(string oldUsername, string newUse

account.Username = newUsername;

await _auditingService.SaveAuditRecordAsync(new UserAuditRecord(account, AuditedUserAction.ChangeUsername));
await _entitiesContext.SaveChangesAsync();

return Json(HttpStatusCode.OK, "Account renamed successfully!", JsonRequestBehavior.AllowGet);
Expand Down

0 comments on commit 0158a73

Please sign in to comment.