private async void SetPasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ResetDisplay();
            SetPassword setPassword = new SetPassword()
            {
                NewPassword = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;
            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.SetPasswordAsync(setPassword);
            }

            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.SavePasswordCredential(this.username, setPassword.NewPassword);
                AccountsSettingsPane.Show();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();

        }
        private async void SetPasswordButton_Click(object sender, RoutedEventArgs e)
        {
            ResetDisplay();
            SetPassword setPassword = new SetPassword()
            {
                NewPassword     = NewPasswordBox.Password,
                ConfirmPassword = ConfirmPasswordBox.Password
            };

            HttpResult result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.SetPasswordAsync(setPassword);
            }

            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.SavePasswordCredential(this.username, setPassword.NewPassword);
                AccountsSettingsPane.Show();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
            ClearPasswords();
        }
Пример #3
0
        private async void SignUpButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();

            // TODO: Add input validation
            string       username     = UsernameTextBox.Text;
            string       password     = PasswordBox.Password;
            RegisterUser registerUser = new RegisterUser()
            {
                UserName        = username,
                Password        = password,
                ConfirmPassword = this.ConfirmPasswordBox.Password
            };

            HttpResult registerResult;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                registerResult = await accountClient.RegisterAsync(registerUser);

                if (!registerResult.Succeeded)
                {
                    DisplayErrors(registerResult.Errors);
                    return;
                }

                HttpResult <AccessTokenResponse> loginResult = await accountClient.LoginAsync(username, password);

                if (loginResult.Succeeded)
                {
                    AppSettings settings = new AppSettings();
                    settings.SavePasswordCredential(username, password);
                    bool resultSet = accessTokenSource.TrySetResult(loginResult.Content.AccessToken);
                    this.Frame.Navigate(typeof(TodoPage));
                }
                else
                {
                    DisplayErrors(loginResult.Errors);
                }
            }
        }
Пример #4
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();

            string username = UsernameTextBox.Text;
            string password = PasswordBox.Password;
            HttpResult <AccessTokenResponse> result;

            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.LoginAsync(username, password);
            }
            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.SavePasswordCredential(username, password);
                bool completed = accessTokenSource.TrySetResult(result.Content.AccessToken);
                this.Frame.GoBack();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
        }
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();

            string username = UsernameTextBox.Text;
            string password = PasswordBox.Password;
            HttpResult<AccessTokenResponse> result;
            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                result = await accountClient.LoginAsync(username, password);
            }
            if (result.Succeeded)
            {
                AppSettings settings = new AppSettings();
                settings.SavePasswordCredential(username, password);
                bool completed = accessTokenSource.TrySetResult(result.Content.AccessToken);
                this.Frame.GoBack();
            }
            else
            {
                DisplayErrors(result.Errors);
            }
        }
        private async void SignUpButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrors();

            // TODO: Add input validation
            string username = UsernameTextBox.Text;
            string password = PasswordBox.Password;
            RegisterUser registerUser = new RegisterUser()
            {
                UserName = username,
                Password = password,
                ConfirmPassword = this.ConfirmPasswordBox.Password
            };

            HttpResult registerResult;
            using (AccountClient accountClient = ClientFactory.CreateAccountClient())
            {
                registerResult = await accountClient.RegisterAsync(registerUser);
                if (!registerResult.Succeeded)
                {
                    DisplayErrors(registerResult.Errors);
                    return;
                }

                HttpResult<AccessTokenResponse> loginResult = await accountClient.LoginAsync(username, password);
                if (loginResult.Succeeded)
                {
                    AppSettings settings = new AppSettings();
                    settings.SavePasswordCredential(username, password);
                    bool resultSet = accessTokenSource.TrySetResult(loginResult.Content.AccessToken);
                    this.Frame.Navigate(typeof(TodoPage));
                }
                else
                {
                    DisplayErrors(loginResult.Errors);
                }
            }
        }