public void ConfirmButton() { _logger.Info($"Button for confirming inputed data pressed."); if (UserNameText.Length > 0 && PasswordText.Length > 0) { _logger.Info($"User name lenght OK and password lengts OK"); LoginAuthenticator authenticator = new LoginAuthenticator(UserNameText, PasswordText, _reamProvider); AuthenticationResultEnum result = authenticator.Authenticate(); _logger.Info($"Authentication of inputed data rresult: {result.ToString()}."); GenerateLoginErrorString(result); if (result == AuthenticationResultEnum.LoginSuccessfull) { _logger.Info($"Login successfull."); GetLoggedUserData(authenticator); TryClose(); } else { _logger.Info($"Login failed."); UserNameText = ""; PasswordText = ""; } } }
private void GenerateLoginErrorString(AuthenticationResultEnum authRes) { switch (authRes) { case AuthenticationResultEnum.UsedDoesNotExist: LoginErrorText = "This user does not exist"; break; case AuthenticationResultEnum.InternalError: LoginErrorText = "Internal login error"; break; case AuthenticationResultEnum.WrongPassword: LoginErrorText = "Password does not match"; break; case AuthenticationResultEnum.LoginSuccessfull: LoginErrorText = ""; break; default: LoginErrorText = "Unknown login error"; break; } }