コード例 #1
0
        public async Task ValidateAndExecuteAsync()
        {
            var verificationType = await _keyConnectorService.GetUsesKeyConnector()
                ? VerificationType.OTP
                : VerificationType.MasterPassword;

            switch (verificationType)
            {
            case VerificationType.MasterPassword:
                var(password, valid) = await _passwordRepromptService.ShowPasswordPromptAndGetItAsync();

                if (!valid)
                {
                    return;
                }

                var parameters = GetParameters();
                parameters.Secret = await _cryptoService.HashPasswordAsync(password, null);

                parameters.VerificationType = VerificationType.MasterPassword;
                await ExecuteAsync(parameters);

                break;

            case VerificationType.OTP:
                await Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(
                                                                                 new VerificationCodePage(_verificationCodeMainActionText, _isVerificationCodeMainActionStyleDanger)));

                break;

            default:
                throw new NotImplementedException($"There is no implementation for {verificationType}");
            }
        }
コード例 #2
0
        public async Task DeleteAccountAsync()
        {
            try
            {
                if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None)
                {
                    await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage,
                                                                AppResources.InternetConnectionRequiredTitle, AppResources.Ok);

                    return;
                }

                var(password, valid) = await _passwordRepromptService.ShowPasswordPromptAndGetItAsync();

                if (!valid)
                {
                    return;
                }

                await _deviceActionService.ShowLoadingAsync(AppResources.DeletingYourAccount);

                var masterPasswordHashKey = await _cryptoService.HashPasswordAsync(password, null);

                await _apiService.DeleteAccountAsync(new Core.Models.Request.DeleteAccountRequest
                {
                    MasterPasswordHash = masterPasswordHashKey
                });

                await _deviceActionService.HideLoadingAsync();

                _messagingService.Send("logout");

                await _platformUtilsService.ShowDialogAsync(AppResources.YourAccountHasBeenPermanentlyDeleted);
            }
            catch (ApiException apiEx)
            {
                await _deviceActionService.HideLoadingAsync();

                if (apiEx?.Error != null)
                {
                    await _platformUtilsService.ShowDialogAsync(apiEx.Error.GetSingleMessage(), AppResources.AnErrorHasOccurred);
                }
            }
            catch (System.Exception ex)
            {
                await _deviceActionService.HideLoadingAsync();

#if !FDROID
                Crashes.TrackError(ex);
#endif
                await _platformUtilsService.ShowDialogAsync(AppResources.AnErrorHasOccurred);
            }
        }