Exemplo n.º 1
0
        /// <summary>
        /// Decrypts the user's profile and logs in
        /// </summary>
        /// <returns></returns>
        private async Task EnterProfile(ProfileModel profile, string passphrase)
        {
            try
            {
                // Check the profile and determine if the passphrase is correct
                await KryptPadApi.LoadProfileAsync(profile.Profile, passphrase);


                // Success, tell the app we are signed in
                (App.Current as App).SignInStatus = SignInStatus.SignedInWithProfile;

                // Check if Windows hellow is supported and save the passphrase
                var supported = await KeyCredentialManager.IsSupportedAsync();

                if (supported && SavePassphraseEnabled)
                {
                    // Prompt to save profile passphrase if Windows Hello is enabled
                    StorePassphrase(profile.Id.ToString(), passphrase);
                }

                // When a profile is selected, navigate to main page
                NavigationHelper.Navigate(typeof(ItemsPage), null, NavigationHelper.NavigationType.Main);
            }
            catch (WebException)
            {
                // Something went wrong in the api
                await DialogHelper.ShowMessageDialogAsync(ResourceHelper.GetString("UnlockProfileFailed"));
            }
            catch (Exception ex)
            {
                // Failed
                await DialogHelper.ShowGenericErrorDialogAsync(ex);
            }
        }
Exemplo n.º 2
0
        private async Task SaveProfile()
        {
            try
            {
                // Create a new profile
                var request = new CreateProfileRequest()
                {
                    Name              = ProfileName,
                    Passphrase        = ProfilePassphrase,
                    ConfirmPassphrase = ConfirmProfilePassphrase
                };

                // Call api to create the profile.
                var profile = await KryptPadApi.CreateProfileAsync(request);

                // Go to profile
                await KryptPadApi.LoadProfileAsync(profile, ProfilePassphrase);

                // Success, tell the app we are signed in
                (App.Current as App).SignInStatus = SignInStatus.SignedInWithProfile;

                // Redirect to the main item list page
                NavigationHelper.Navigate(typeof(ItemsPage), null, NavigationHelper.NavigationType.Main);

                // Hide the dialog
                Hide();
            }
            catch (WebException ex)
            {
                // Something went wrong in the api
                await DialogHelper.ShowMessageDialogAsync(ex.Message);
            }
            catch (Exception ex)
            {
                // Failed
                await DialogHelper.ShowGenericErrorDialogAsync(ex);
            }
        }