private async Task AddSharedAccoountAsync() { try { var account = await EmployeeService.AddSharedAccountAsync(EmployeeId, SelectedSharedAccount.Id); var employee = await EmployeeService.GetEmployeeByIdAsync(account.EmployeeId); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(employee.HardwareVaults.Select(x => x.Id).ToArray()); await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Account added and will be recorded when the device is connected to the server.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, EmployeeId); await ModalDialogService.CloseAsync(); } catch (Exception ex) { await ModalDialogService.CloseAsync(); Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task EditAccountOtpAsync() { try { await ButtonSpinner.SpinAsync(async() => { await EmployeeService.EditPersonalAccountOtpAsync(Account, _accountOtp); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(Account.EmployeeId)); await ToastService.ShowToastAsync("Account OTP updated.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); }); } catch (IncorrectOtpException ex) { ValidationErrorMessage.DisplayError(nameof(AccountOtp.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
private async Task OpenModalDisableSsoAsync() { if (!await VerifyAdUserAsync()) { return; } RenderFragment body = (builder) => { builder.OpenComponent(0, typeof(EmployeeDisableSso)); builder.AddAttribute(1, nameof(EmployeeDisableSso.Employee), Employee); builder.CloseComponent(); }; var instance = await ModalDialogService.ShowAsync("Disable SSO", body); var result = await instance.Result; if (result.Succeeded) { await LoadEmployeeSsoState(); await SynchronizationService.UpdateEmployeeDetails(PageId, EmployeeId); } }
private async Task OpenDialogAddSharedAccountAsync() { if (!await VerifyAdUserAsync()) { return; } RenderFragment body = (builder) => { builder.OpenComponent(0, typeof(AddSharedAccount)); builder.AddAttribute(1, nameof(AddSharedAccount.EmployeeId), EmployeeId); builder.CloseComponent(); }; var instance = await ModalDialogService.ShowAsync("Add shared account", body, ModalDialogSize.Large); var result = await instance.Result; if (result.Succeeded) { await LoadEmployeeAsync(); await DataTableService.LoadTableDataAsync(); await SynchronizationService.UpdateEmployeeDetails(PageId, EmployeeId); } }
private async Task OpenDialogDeleteAccountAsync() { if (!await VerifyAdUserAsync()) { return; } RenderFragment body = (builder) => { builder.OpenComponent(0, typeof(DeleteAccount)); builder.AddAttribute(1, nameof(DeleteAccount.AccountId), DataTableService.SelectedEntity.Id); builder.CloseComponent(); }; var instance = await ModalDialogService.ShowAsync("Delete Account", body); var result = await instance.Result; if (result.Succeeded) { await DataTableService.LoadTableDataAsync(); await SynchronizationService.UpdateEmployeeDetails(PageId, EmployeeId); } }
private async Task CreateAccountAsync() { try { await ButtonSpinner.SpinAsync(async() => { await EmployeeService.CreatePersonalAccountAsync(PersonalAccount); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(EmployeeId)); await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Account created.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, EmployeeId); await ModalDialogService.CloseAsync(); }); } catch (AlreadyExistException ex) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.Name), ex.Message); } catch (IncorrectUrlException ex) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.Urls), ex.Message); } catch (IncorrectOtpException ex) { ValidationErrorMessage.DisplayError(nameof(PersonalAccount.OtpSecret), ex.Message); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task OpenDialogRemoveHardwareVaultAsync(HardwareVault hardwareVault) { if (!await VerifyAdUserAsync()) { return; } RenderFragment body = (builder) => { builder.OpenComponent(0, typeof(DeleteHardwareVault)); builder.AddAttribute(1, nameof(DeleteHardwareVault.HardwareVaultId), hardwareVault.Id); builder.CloseComponent(); }; var instance = await ModalDialogService.ShowAsync("Delete hardware vault", body); var result = await instance.Result; if (result.Succeeded) { await LoadEmployeeAsync(); await SynchronizationService.UpdateEmployeeDetails(PageId, EmployeeId); } }
private async Task EditAccountPasswordAsync() { try { await ButtonSpinner.SpinAsync(async() => { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await EmployeeService.EditPersonalAccountPwdAsync(Account, _accountPassword); if (_accountPassword.UpdateActiveDirectoryPassword) { await LdapService.SetUserPasswordAsync(Account.EmployeeId, _accountPassword.Password, LdapSettings); } transactionScope.Complete(); } RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(Account.EmployeeId)); await ToastService.ShowToastAsync("Account password updated.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CloseAsync(); } }
public async Task DeleteVaultAsync() { try { var employeeId = HardwareVault.EmployeeId; await EmployeeService.RemoveHardwareVaultAsync(HardwareVault.Id, Reason, IsNeedBackup); await Refresh.InvokeAsync(this); RemoteDeviceConnectionsService.StartUpdateHardwareVaultStatus(HardwareVault.Id); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, employeeId); await SynchronizationService.HardwareVaultStateChanged(HardwareVault.Id); await ToastService.ShowToastAsync("Vault removed.", ToastType.Success); await ModalDialogService.CloseAsync(); } catch (Exception ex) { Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task SetAsWorkstationAccountAsync() { try { await EmployeeService.SetAsPrimaryAccountAsync(Account.Employee.Id, Account.Id); var employee = await EmployeeService.GetEmployeeByIdAsync(Account.Employee.Id); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(employee.Id)); await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Account setted as primary.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); } catch (Exception ex) { await ModalDialogService.CloseAsync(); Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task AddVaultAsync() { try { if (SelectedHardwareVault == null) { WarningMessage = "Please, select a vault."; return; } using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await EmployeeService.AddHardwareVaultAsync(EmployeeId, SelectedHardwareVault.Id); var ldapSettings = await AppSettingsService.GetLdapSettingsAsync(); if (ldapSettings?.Password != null) { var employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId); if (employee.ActiveDirectoryGuid != null) { await LdapService.AddUserToHideezKeyOwnersAsync(ldapSettings, employee.ActiveDirectoryGuid); } } transactionScope.Complete(); } await Refresh.InvokeAsync(this); await ToastService.ShowToastAsync("Vault added", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, EmployeeId); await SynchronizationService.HardwareVaultStateChanged(SelectedHardwareVault.Id); await ModalDialogService.CloseAsync(); } catch (Exception ex) { await ModalDialogService.CloseAsync(); Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task DeleteAccoountAsync() { try { var account = await EmployeeService.DeleteAccountAsync(Account.Id); RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(account.EmployeeId)); await ToastService.ShowToastAsync("Account deleted.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); } catch (Exception ex) { Logger.LogError(ex.Message, ex); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }
private async Task GenerateAccountPasswordAsync() { try { if (LdapSettings?.Password == null) { throw new Exception("Active Directory credentials not set in parameters page."); } var accountPassword = new AccountPassword() { Password = PasswordGenerator.Generate() }; using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await EmployeeService.EditPersonalAccountPwdAsync(Account, accountPassword); await LdapService.SetUserPasswordAsync(Account.EmployeeId, accountPassword.Password, LdapSettings); transactionScope.Complete(); } RemoteDeviceConnectionsService.StartUpdateHardwareVaultAccounts(await EmployeeService.GetEmployeeVaultIdsAsync(Account.EmployeeId)); await ToastService.ShowToastAsync("Account password updated.", ToastType.Success); await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, Account.EmployeeId); await ModalDialogService.CloseAsync(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }