Example #1
0
        private void TransitionerBackToUser_OnClick(object sender, RoutedEventArgs e)
        {
            if (LoginTransitioner.SelectedIndex != 0)
            {
                LoginTransitioner.SelectedIndex = 0;
            }

            PasswordBox.Clear();
            ShowPasswordBox.Clear();
            LoginPasswordBox.Clear();
            ShowLoginPasswordBox.Clear();
            ConfirmPasswordBox.Clear();
            ShowConfirmPasswordBox.Clear();
            MonobankApiKey.Clear();
            ForgotPasswordCheckMonobankApiKey.Clear();

            Transitioner.SelectedIndex = 1;
        }
Example #2
0
        private async void ForgotPassword_OnClick(object sender, RoutedEventArgs e)
        {
            var user = ((AuthViewModel)DataContext).UserList[((AuthViewModel)DataContext).SelectedUserIndex];

            if (Internet.IsConnectedToInternet() is false)
            {
                ((AuthViewModel)DataContext).Messages.Clear();
                ((AuthViewModel)DataContext).Messages.Enqueue(App.GetResourceValue("MbNoInternet") !);

                return;
            }

            var(isSuccess, clientIdOrMessage) = await GetUserInfo.GetClientIdAsync(ForgotPasswordCheckMonobankApiKey.Text);

            var isEqualToken = user.MonoboardUser.AccessToken == ForgotPasswordCheckMonobankApiKey.Text;

            if (isEqualToken)
            {
                await AlertDialog.ShowDialogAsync(DialogHost, new AlertDialogArguments
                {
                    Title                 = App.GetResourceValue("MbPasswordResetTitle"),
                    Message               = App.GetResourceValue("MbPasswordResetDescription"),
                    OkButtonLabel         = App.GetResourceValue("MbClose"),
                    CustomContent         = new ForgotPasswordViewModel(user.ClientId),
                    CustomContentTemplate = FindResource("ForgotPasswordViewModelTemplate") as DataTemplate,
                }).ContinueWith(delegate
                {
                    Application.Current.Dispatcher.BeginInvoke(delegate
                    {
                        Transitioner.SelectedIndex = 4;
                    });
                });
            }
            else if (isSuccess)
            {
                if (string.Equals(clientIdOrMessage, user.ClientId))
                {
                    await AlertDialog.ShowDialogAsync(DialogHost, new AlertDialogArguments
                    {
                        Title                 = App.GetResourceValue("MbPasswordResetTitle"),
                        Message               = App.GetResourceValue("MbPasswordResetDescription"),
                        OkButtonLabel         = App.GetResourceValue("MbClose"),
                        CustomContent         = new ForgotPasswordViewModel(user.ClientId),
                        CustomContentTemplate = FindResource("ForgotPasswordViewModelTemplate") as DataTemplate,
                    }).ContinueWith(delegate
                    {
                        Application.Current.Dispatcher.BeginInvoke(delegate
                        {
                            Transitioner.SelectedIndex = 4;
                        });
                    });
                }
                else
                {
                    await AlertDialog.ShowDialogAsync(DialogHost, new AlertDialogArguments
                    {
                        Title         = App.GetResourceValue("MbPasswordResetTitle"),
                        Message       = App.GetResourceValue("MbWrongAccount"),
                        OkButtonLabel = App.GetResourceValue("MbClose")
                    }).ContinueWith(delegate
                    {
                        Application.Current.Dispatcher.BeginInvoke(delegate
                        {
                            ForgotPasswordCheckMonobankApiKey.Clear();
                            Transitioner.SelectedIndex = 1;
                        });
                    });
                }
            }
            else
            {
                await AlertDialog.ShowDialogAsync(DialogHost, new AlertDialogArguments
                {
                    Title         = App.GetResourceValue("MbPasswordResetTitle"),
                    Message       = App.GetResourceValue("MbNoInternet"),
                    OkButtonLabel = App.GetResourceValue("MbClose")
                }).ContinueWith(delegate
                {
                    Application.Current.Dispatcher.BeginInvoke(delegate
                    {
                        ForgotPasswordCheckMonobankApiKey.Clear();
                        Transitioner.SelectedIndex = 1;
                    });
                });
            }
        }