Stash and player management fix

This commit is contained in:
dingo
2025-12-26 20:23:10 -05:00
parent 28b816553d
commit 7d3514ede7
6 changed files with 195 additions and 22 deletions
+9 -20
View File
@@ -21,7 +21,11 @@ public class EditModel : AdminPageModel
public List<DungeonCharacter> Characters { get; set; } = new();
public bool IsNew => Account.Id == 0;
[TempData]
public string? Message { get; set; }
[TempData]
public bool IsError { get; set; }
public async Task<IActionResult> OnGetAsync(ulong? id)
@@ -147,26 +151,16 @@ public class EditModel : AdminPageModel
if (string.IsNullOrWhiteSpace(newPassword) || newPassword.Length < 6)
{
Account = account;
Characters = await _db.DungeonCharacters
.Where(c => c.AccountId == accountId && !c.IsDeleted)
.OrderByDescending(c => c.Level)
.ToListAsync();
Message = "Password must be at least 6 characters.";
IsError = true;
return Page();
return RedirectToPage(new { id = accountId });
}
if (newPassword != confirmPassword)
{
Account = account;
Characters = await _db.DungeonCharacters
.Where(c => c.AccountId == accountId && !c.IsDeleted)
.OrderByDescending(c => c.Level)
.ToListAsync();
Message = "Passwords do not match.";
IsError = true;
return Page();
return RedirectToPage(new { id = accountId });
}
_passwordHasher.Hash(newPassword, out var hash, out var salt);
@@ -174,13 +168,8 @@ public class EditModel : AdminPageModel
account.PasswordSalt = salt;
await _db.SaveChangesAsync();
Account = account;
Characters = await _db.DungeonCharacters
.Where(c => c.AccountId == accountId && !c.IsDeleted)
.OrderByDescending(c => c.Level)
.ToListAsync();
Message = "Password has been reset.";
return Page();
Message = "Password has been reset successfully.";
IsError = false;
return RedirectToPage(new { id = accountId });
}
}