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();
            }
        }
示例#2
0
        private async Task EditAsync()
        {
            try
            {
                await ButtonSpinner.SpinAsync(async() =>
                {
                    await OrgStructureService.EditDepartmentAsync(Department);
                    await ToastService.ShowToastAsync("Department updated.", ToastType.Success);
                    await Refresh.InvokeAsync(this);
                    await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId);
                    await ModalDialogService.CloseAsync();
                });
            }
            catch (AlreadyExistException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(Department.Name), ex.Message);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
        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);
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        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);
            }
        }
示例#7
0
        private async Task SaveSecurityKeyAsync()
        {
            try
            {
                await FidoService.UpdateSecurityKeyNameAsync(FidoStoredCredential.Id, SecurityKeyName);

                await Refresh.InvokeAsync();

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
示例#8
0
        public async Task SendAsync()
        {
            try
            {
                await SoftwareVaultService.ResendInvitationAsync(SoftwareVaultInvitation.Employee, ServerSettings, SoftwareVaultInvitation.Id);

                await Refresh.InvokeAsync(this);

                await ToastService.ShowToastAsync("Invitation sent.", ToastType.Success);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
            }
            finally
            {
                await ModalDialogService.CloseAsync();
            }
        }
示例#9
0
        public async Task DeleteAsync()
        {
            try
            {
                await SoftwareVaultService.DeleteInvitationAsync(SoftwareVaultInvitation.Id);

                await Refresh.InvokeAsync(this);

                await ToastService.ShowToastAsync("Invitation deleted.", ToastType.Success);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
            }
            finally
            {
                await ModalDialogService.CloseAsync();
            }
        }
示例#10
0
        private async Task UpdateSecurityKeyAsync()
        {
            try
            {
                await FidoService.UpdateSecurityKeyNameAsync(SecurityKeyId, SecurityKeyName);

                await ToastService.ShowToastAsync("Security key updated.", ToastType.Success);

                await Refresh.InvokeAsync();

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
示例#11
0
        private async Task VerifyTwoFactorAsync()
        {
            try
            {
                var response = await HttpClient.PostAsync("api/Identity/VerifyTwoFactor", (new StringContent(JsonConvert.SerializeObject(VerificationCode), Encoding.UTF8, "application/json")));

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception(await response.Content.ReadAsStringAsync());
                }

                var verifyTwoFactorTokenInfo = JsonConvert.DeserializeObject <VerifyTwoFactorInfo>(await response.Content.ReadAsStringAsync());

                if (!verifyTwoFactorTokenInfo.IsTwoFactorTokenValid)
                {
                    await ToastService.ShowToastAsync("Verification code is invalid.", ToastType.Error);

                    return;
                }

                await ToastService.ShowToastAsync("Your authenticator app has been verified.", ToastType.Success);

                await Refresh.InvokeAsync();

                if (verifyTwoFactorTokenInfo.RecoveryCodes != null)
                {
                    RecoveryCodes = verifyTwoFactorTokenInfo.RecoveryCodes.ToArray();
                }
                else
                {
                    await ModalDialogService.CloseAsync();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
示例#12
0
        public async Task DeleteAsync()
        {
            try
            {
                await OrgStructureService.DeleteDepartmentAsync(Department.Id);

                await Refresh.InvokeAsync(this);

                await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId);

                await ToastService.ShowToastAsync("Department removed.", ToastType.Success);

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                await ModalDialogService.CancelAsync();

                Logger.LogError(ex.Message, ex);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
            }
        }
 private async Task EnableDataProtectionAsync()
 {
     try
     {
         await ButtonSpinner.SpinAsync(async() =>
         {
             var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
             await DataProtectionService.EnableProtectionAsync(NewPassword.Password);
             await Refresh.InvokeAsync(this);
             await ToastService.ShowToastAsync("Data protection enabled.", ToastType.Success);
             await SynchronizationService.UpdateDataProtection(ExceptPageId);
             Logger.LogInformation($"Data protection enabled by {authState.User.Identity.Name}");
         });
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message);
         await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
     }
     finally
     {
         await ModalDialogService.CloseAsync();
     }
 }