@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Setting.SystemUser @using Indotalent.Features.Setting.SystemUser.Cqrs @using MudBlazor @using Indotalent.Shared.Utils @inject SystemUserService SystemUserService @inject ISnackbar Snackbar
@(ReadOnly ? "User Details" : "Edit User") @(ReadOnly ? "View complete user account information." : "Update account details and security settings.")
Primary Information Full Name Email Address & Username Email and Username cannot be changed. Username is linked to the email address. Phone Number SSO Identifiers Firebase ID Keycloak ID Azure ID AWS ID Other SSO ID 1 Other SSO ID 2 Other SSO ID 3 Account Settings & Status
General availability of the account in the system.
Current status of email verification.
Current status of phone number verification.
Requirement for Two-Factor Authentication.
Allow account to be locked after failed attempts.
Lockout Until Current account lockout expiration date.
Audit History Created At @DateTimeExtensions.ToString(_model.CreatedAt) Last Login At @DateTimeExtensions.ToString(_model.LastLoginAt) Last Updated At @DateTimeExtensions.ToString(_model.UpdatedAt)
@(ReadOnly ? "Back to List" : "Cancel") @if (!ReadOnly) { @if (_processing) { Processing... } else { Save Changes } }
@code { [Parameter] public UpdateSystemUserRequest Data { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private UpdateSystemUserRequest _model = new(); private UpdateSystemUserValidator _validator = new(); private DateTime? _lockoutDate; private bool _processing = false; protected override void OnInitialized() { _model = new UpdateSystemUserRequest { Id = Data.Id, UserName = Data.UserName, FullName = Data.FullName, Email = Data.Email, PhoneNumber = Data.PhoneNumber, EmailConfirmed = Data.EmailConfirmed, PhoneNumberConfirmed = Data.PhoneNumberConfirmed, TwoFactorEnabled = Data.TwoFactorEnabled, IsActive = Data.IsActive, LockoutEnabled = Data.LockoutEnabled, LockoutEnd = Data.LockoutEnd, SsoIdFirebase = Data.SsoIdFirebase, SsoIdKeycloak = Data.SsoIdKeycloak, SsoIdAzure = Data.SsoIdAzure, SsoIdAws = Data.SsoIdAws, SsoIdOther1 = Data.SsoIdOther1, SsoIdOther2 = Data.SsoIdOther2, SsoIdOther3 = Data.SsoIdOther3, CreatedAt = Data.CreatedAt, LastLoginAt = Data.LastLoginAt, UpdatedAt = Data.UpdatedAt }; if (_model.LockoutEnd.HasValue) { _lockoutDate = _model.LockoutEnd.Value.DateTime; } } private async Task Submit() { if (ReadOnly) return; await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { if (_lockoutDate.HasValue) { _model.LockoutEnd = new DateTimeOffset(_lockoutDate.Value, TimeSpan.Zero); } else { _model.LockoutEnd = null; } var response = await SystemUserService.UpdateSystemUserAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("User updated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } catch (Exception ex) { Snackbar.Add($"Error: {ex.Message}", Severity.Error); } finally { _processing = false; } } }