Restore clean role-change success message
Drop the temporary "saved: …" diagnostic wording now that the production interactivity bug is fixed. Keeps the robust @onchange handler and the previous-role return value used in the audit entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -195,24 +195,15 @@ else
|
||||
|
||||
private async Task OnRoleChange(AppUser user, ChangeEventArgs e)
|
||||
{
|
||||
// Surface every branch on-screen so a failed save is never silent. The "saved" value is
|
||||
// re-read from the store, so it proves whether the write actually landed on disk.
|
||||
var raw = e.Value?.ToString();
|
||||
if (!Enum.TryParse<UserRole>(raw, out var newRole))
|
||||
{
|
||||
_message = string.Format(T["usermgmt.msg.error"], $"unrecognized role value '{raw}'");
|
||||
_isError = true;
|
||||
return;
|
||||
}
|
||||
if (!Enum.TryParse<UserRole>(e.Value?.ToString(), out var newRole)) return;
|
||||
try
|
||||
{
|
||||
var oldRole = await UserService.UpdateRoleAsync(user.Id, newRole);
|
||||
user.Role = newRole;
|
||||
var saved = (await UserService.GetByEmailAsync(user.Email))?.Role;
|
||||
await Audit.LogAsync("RoleChanged", "", Array.Empty<string>(),
|
||||
$"Changed role for {user.Email} ({user.DisplayName}) from {oldRole} to {newRole}.");
|
||||
_message = $"{string.Format(T["usermgmt.msg.roleupdated"], user.DisplayName)} ({oldRole} → {newRole}, saved: {saved})";
|
||||
_isError = saved != newRole;
|
||||
_message = string.Format(T["usermgmt.msg.roleupdated"], user.DisplayName);
|
||||
_isError = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user