Пример #1
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;
                }

                await _verificationActionsFlowHelper
                .Configure(VerificationFlowAction.DeleteAccount,
                           null,
                           AppResources.DeleteAccount,
                           true)
                .ValidateAndExecuteAsync();
            }
            catch (System.Exception ex)
            {
#if !FDROID
                Crashes.TrackError(ex);
#endif
                await _platformUtilsService.ShowDialogAsync(AppResources.AnErrorHasOccurred);
            }
        }
Пример #2
0
        public async Task Execute(IActionFlowParmeters parameters)
        {
            try
            {
                await _deviceActionService.ShowLoadingAsync(AppResources.DeletingYourAccount);

                await _apiService.DeleteAccountAsync(new Core.Models.Request.DeleteAccountRequest
                {
                    MasterPasswordHash = parameters.VerificationType == Core.Enums.VerificationType.MasterPassword ? parameters.Secret : (string)null,
                    OTP = parameters.VerificationType == Core.Enums.VerificationType.OTP ? parameters.Secret : (string)null
                });

                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();

                _logger.Exception(ex);
                await _platformUtilsService.ShowDialogAsync(AppResources.AnErrorHasOccurred);
            }
        }
Пример #3
0
        public async Task AboutAsync()
        {
            var debugText = string.Format("{0}: {1} ({2})", AppResources.Version,
                                          _platformUtilsService.GetApplicationVersion(), _deviceActionService.GetBuildNumber());

#if DEBUG
            var pushNotificationsRegistered = ServiceContainer.Resolve <IPushNotificationService>("pushNotificationService").IsRegisteredForPush;
            var pnServerRegDate             = await _stateService.GetPushLastRegistrationDateAsync();

            var pnServerError = await _stateService.GetPushInstallationRegistrationErrorAsync();

            var pnServerRegDateMessage = default(DateTime) == pnServerRegDate ? "-" : $"{pnServerRegDate.GetValueOrDefault().ToShortDateString()}-{pnServerRegDate.GetValueOrDefault().ToShortTimeString()} UTC";
            var errorMessage           = string.IsNullOrEmpty(pnServerError) ? string.Empty : $"Push Notifications Server Registration error: {pnServerError}";

            var text = string.Format("© Bitwarden Inc. 2015-{0}\n\n{1}\nPush Notifications registered:{2}\nPush Notifications Server Last Date :{3}\n{4}", DateTime.Now.Year, debugText, pushNotificationsRegistered, pnServerRegDateMessage, errorMessage);
#else
            var text = string.Format("© Bitwarden Inc. 2015-{0}\n\n{1}", DateTime.Now.Year, debugText);
#endif

            var copy = await _platformUtilsService.ShowDialogAsync(text, AppResources.Bitwarden, AppResources.Copy,
                                                                   AppResources.Close);

            if (copy)
            {
                await _clipboardService.CopyTextAsync(debugText);
            }
        }
Пример #4
0
        public async Task SubmitAsync()
        {
            if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None)
            {
                await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage,
                                                            AppResources.InternetConnectionRequiredTitle);

                return;
            }
            if (string.IsNullOrWhiteSpace(Email))
            {
                await Page.DisplayAlert(AppResources.AnErrorHasOccurred,
                                        string.Format(AppResources.ValidationFieldRequired, AppResources.EmailAddress),
                                        AppResources.Ok);

                return;
            }

            // Cozy customization, Email is not an email, it represents the Cozy URL as in
            // the login page : email validation check is disabled.
            if (false && !Email.Contains("@"))
            {
                await Page.DisplayAlert(AppResources.AnErrorHasOccurred, AppResources.InvalidEmail, AppResources.Ok);

                return;
            }

            #region cozy
            var cozyURL = Email;
            await _cozyClientService.ConfigureEnvironmentFromCozyURLAsync(cozyURL);

            #endregion

            try
            {
                await _deviceActionService.ShowLoadingAsync(AppResources.Submitting);

                await _apiService.PostPasswordHintAsync(
                    new Core.Models.Request.PasswordHintRequest {
                    Email = Email
                });

                await _deviceActionService.HideLoadingAsync();

                await Page.DisplayAlert(null, AppResources.PasswordHintAlert, AppResources.Ok);

                await Page.Navigation.PopModalAsync();
            }
            catch (ApiException e)
            {
                await _deviceActionService.HideLoadingAsync();

                if (e?.Error != null)
                {
                    await _platformUtilsService.ShowDialogAsync(e.Error.GetSingleMessage(),
                                                                AppResources.AnErrorHasOccurred);
                }
            }
        }
        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);
            }
        }
Пример #6
0
        public async Task SubmitAsync()
        {
            if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.None)
            {
                await _platformUtilsService.ShowDialogAsync(AppResources.InternetConnectionRequiredMessage,
                                                            AppResources.InternetConnectionRequiredTitle);

                return;
            }
            if (string.IsNullOrWhiteSpace(Email))
            {
                await Page.DisplayAlert(AppResources.AnErrorHasOccurred,
                                        string.Format(AppResources.ValidationFieldRequired, AppResources.EmailAddress),
                                        AppResources.Ok);

                return;
            }
            if (!Email.Contains("@"))
            {
                await Page.DisplayAlert(AppResources.AnErrorHasOccurred, AppResources.InvalidEmail, AppResources.Ok);

                return;
            }

            try
            {
                await _deviceActionService.ShowLoadingAsync(AppResources.Submitting);

                await _apiService.PostPasswordHintAsync(
                    new Core.Models.Request.PasswordHintRequest {
                    Email = Email
                });

                await _deviceActionService.HideLoadingAsync();

                await Page.DisplayAlert(null, AppResources.PasswordHintAlert, AppResources.Ok);

                await Page.Navigation.PopModalAsync();
            }
            catch (ApiException e)
            {
                await _deviceActionService.HideLoadingAsync();

                if (e?.Error != null)
                {
                    await _platformUtilsService.ShowDialogAsync(e.Error.GetSingleMessage(),
                                                                AppResources.AnErrorHasOccurred);
                }
            }
        }
Пример #7
0
        public async Task AboutAsync()
        {
            var debugText = string.Format("{0}: {1} ({2})", AppResources.Version,
                                          _platformUtilsService.GetApplicationVersion(), _deviceActionService.GetBuildNumber());
            var text = string.Format("© Bitwarden Inc. 2015-{0}\n\n{1}", DateTime.Now.Year, debugText);
            var copy = await _platformUtilsService.ShowDialogAsync(text, AppResources.Bitwarden, AppResources.Copy,
                                                                   AppResources.Close);

            if (copy)
            {
                await _platformUtilsService.CopyToClipboardAsync(debugText);
            }
        }
Пример #8
0
        async private Task InvalidSecretErrorAsync(VerificationType verificationType)
        {
            var errorMessage = verificationType == VerificationType.OTP
                ? _i18nService.T("InvalidVerificationCode")
                : _i18nService.T("InvalidMasterPassword");

            await _platformUtilsService.ShowDialogAsync(errorMessage);
        }
Пример #9
0
        private async void LogOut_Clicked(object sender, EventArgs e)
        {
            if (DoOnce())
            {
                var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.LogoutConfirmation,
                                                                            AppResources.LogOut, AppResources.Yes, AppResources.Cancel);

                if (confirmed)
                {
                    _vm.LogOutAction();
                }
            }
        }
Пример #10
0
 private async Task DisplayOnboardedDialogAsync()
 {
     await _platformUtilsService.ShowDialogAsync(AppResources.RegistrationSuccess, AppResources.CozyPass,
                                                 AppResources.Close);
 }