示例#1
0
        private async Task TryLoginPasswordAsync()
        {
            IsAuthenticating = true;
            var        authManager = ServiceContainer.Resolve <AuthManager> ();
            AuthResult authRes;

            try {
                authRes = await authManager.AuthenticateAsync(EmailEditText.Text, PasswordEditText.Text);
            } catch (InvalidOperationException ex) {
                var log = ServiceContainer.Resolve <ILogger> ();
                log.Info(LogTag, ex, "Failed to authenticate user with password.");
                return;
            } finally {
                IsAuthenticating = false;
            }

            if (authRes != AuthResult.Success)
            {
                if (authRes == AuthResult.InvalidCredentials)
                {
                    PasswordEditText.Text = String.Empty;
                }
                PasswordEditText.RequestFocus();

                ShowAuthError(EmailEditText.Text, authRes, Mode.Login);
            }
            else
            {
                // Start the initial sync for the user
                ServiceContainer.Resolve <ISyncManager> ().Run();
            }

            StartAuthActivity();
        }
        private async void TryLoginPassword()
        {
            IsAuthenticating = true;
            var  authManager = ServiceContainer.Resolve <AuthManager> ();
            bool success;

            try {
                success = await authManager.Authenticate(EmailEditText.Text, PasswordEditText.Text);
            } catch (InvalidOperationException ex) {
                var log = ServiceContainer.Resolve <Logger> ();
                log.Info(LogTag, ex, "Failed to authenticate user with password.");
                return;
            } finally {
                IsAuthenticating = false;
            }

            if (!success)
            {
                PasswordEditText.Text = String.Empty;
                PasswordEditText.RequestFocus();

                new InvalidCredentialsDialogFragment().Show(FragmentManager, "invalid_credentials_dialog");
            }
            else
            {
                // Start the initial sync for the user
                ServiceContainer.Resolve <ISyncManager> ().Run(SyncMode.Full);
            }

            StartAuthActivity();
        }
示例#3
0
        /// <summary>
        /// Evenement lorsque l'Edit Text du password de la page CreateAccount change
        /// </summary>
        private void OnPasswordTextChanged(object sender, EventArgs e)
        {
            App.Locator.Login.UserPassword = PasswordEditText.Text;
            if (PasswordEditText.Text.Length < 8)
            {
                PasswordEditText.SetError(Resources.GetString(Resource.String.login_password_error), null);
                if (timer != null)
                {
                    timer.Cancel();
                }
            }
            else
            {
                PasswordEditText.SetError(string.Empty, null);
                switch ((int)PasswordComplexityHelper.CheckStrength(PasswordEditText.Text))
                {
                case (int)PasswordComplexityHelper.PasswordScore.Weak:
                    var spanString0 = Resources.GetString(Resource.String.login_password_weak);
                    var spanText0   = string.Format(spanString0, Resources.GetString(Resource.String.login_weak));

                    var resultTuple0       = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(spanString0, Resources.GetString(Resource.String.login_weak));
                    var formattedinfoText0 = new SpannableString(spanText0);
                    formattedinfoText0.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.Red)), resultTuple0.Item1, resultTuple0.Item2, 0);

                    PasswordEditText.SetError(formattedinfoText0, null);
                    break;

                case (int)PasswordComplexityHelper.PasswordScore.Medium:

                    var spanString = Resources.GetString(Resource.String.login_password_medium);
                    var spanText   = string.Format(spanString, Resources.GetString(Resource.String.login_medium));

                    var resultTuple       = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(spanString, Resources.GetString(Resource.String.login_medium));
                    var formattedinfoText = new SpannableString(spanText);
                    formattedinfoText.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.Orange)), resultTuple.Item1, resultTuple.Item2, 0);

                    PasswordEditText.SetError(formattedinfoText, null);
                    break;

                case (int)PasswordComplexityHelper.PasswordScore.Strong:
                case (int)PasswordComplexityHelper.PasswordScore.VeryStrong:

                    var spanString1 = Resources.GetString(Resource.String.login_password_strong);
                    var spanText1   = string.Format(spanString1, Resources.GetString(Resource.String.login_strong));

                    var resultTuple1       = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(spanString1, Resources.GetString(Resource.String.login_strong));
                    var formattedinfoText1 = new SpannableString(spanText1);
                    formattedinfoText1.SetSpan(new ForegroundColorSpan(Color.ParseColor(App.MainColor)), resultTuple1.Item1, resultTuple1.Item2, 0);

                    PasswordEditText.SetError(formattedinfoText1, null);
                    break;
                }
                LaunchTimerToHideError();
            }
            if (string.IsNullOrEmpty(PasswordEditText.Text))
            {
                PasswordEditText.Error = null;
            }
        }
示例#4
0
        private async Task TryLoginPasswordAsync()
        {
            var authRes = await ViewModel.TryLoginPasswordAsync(EmailEditText.Text, PasswordEditText.Text);

            if (authRes != AuthResult.Success)
            {
                if (authRes == AuthResult.InvalidCredentials)
                {
                    PasswordEditText.Text = String.Empty;
                }
                PasswordEditText.RequestFocus();

                ShowAuthError(EmailEditText.Text, authRes, Mode.Login);
            }
        }
示例#5
0
        private async void TryLoginPassword()
        {
            IsAuthenticating = true;
            var authManager = ServiceContainer.Resolve <AuthManager> ();
            var success     = await authManager.Authenticate(EmailEditText.Text, PasswordEditText.Text);

            IsAuthenticating = false;

            if (!success)
            {
                PasswordEditText.Text = String.Empty;
                PasswordEditText.RequestFocus();

                new InvalidCredentialsDialogFragment().Show(FragmentManager, "invalid_credentials_dialog");
            }

            StartAuthActivity();
        }
示例#6
0
        private void SyncPasswordVisibility()
        {
            if (PasswordEditText.Text.Length == 0)
            {
                // Reset buttons and mask
                PasswordToggleButton.Visibility = ViewStates.Gone;
                showPassword = false;
            }
            else if (showPassword)
            {
                PasswordToggleButton.SetText(Resource.String.LoginHideButtonText);
                PasswordToggleButton.Visibility = ViewStates.Visible;
            }
            else
            {
                PasswordToggleButton.SetText(Resource.String.LoginShowButtonText);
                PasswordToggleButton.Visibility = ViewStates.Visible;
            }

            int selectionStart = PasswordEditText.SelectionStart;
            int selectionEnd   = PasswordEditText.SelectionEnd;

            var passwordInputType = PasswordEditText.InputType;

            if (showPassword)
            {
                passwordInputType = (passwordInputType & ~InputTypes.TextVariationPassword) | InputTypes.TextVariationVisiblePassword;
            }
            else
            {
                passwordInputType = (passwordInputType & ~InputTypes.TextVariationVisiblePassword) | InputTypes.TextVariationPassword;
            }
            if (PasswordEditText.InputType != passwordInputType)
            {
                PasswordEditText.InputType = passwordInputType;

                // Need to reset font after changing input type
                PasswordEditText.SetFont(Font.RobotoLight);

                // Restore cursor position:
                PasswordEditText.SetSelection(selectionStart, selectionEnd);
            }
        }