Example #1
0
        /// <summary>
        /// Reset button click event or Login Id/SecurityAnswer Enter Press event implementation - validate errors, navigate to notification screen
        /// </summary>
        /// <param name="param"></param>
        private void ResetCommandMethod(object param)
        {
            try
            {
                if (_manageLogins != null)
                {
                    if (ErrorValidation())
                    {
                        #region GetUser Service Call
                        _manageLogins.GetUser(LoginIdText, false, (membershipUser) =>
                        {
                            string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);
                            Logging.LogLoginBeginMethod(_logger, methodNamespace, LoginIdText);

                            try
                            {
                                if (membershipUser != null)
                                {
                                    Logging.LogLoginMethodParameter(_logger, methodNamespace, membershipUser, 1, _loginIdText);

                                    #region ResetPassword Service Call
                                    _manageLogins.ResetPassword(LoginIdText, SecurityAnswerText, (password) =>
                                    {
                                        string resetMethodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);
                                        Logging.LogLoginBeginMethod(_logger, resetMethodNamespace, LoginIdText);

                                        try
                                        {
                                            if (password != null)
                                            {
                                                Logging.LogLoginMethodParameter(_logger, resetMethodNamespace, password, 1, _loginIdText);
                                                Logging.LogAccountPasswordReset(_logger, LoginIdText);
                                                Prompt.ShowDialog(password); // Password displayed as messagebox, to be sent as email alert later
                                                ResourceManager NotificationManager = new ResourceManager(typeof(Notifications));
                                                NotificationText = NotificationManager.GetString("PasswordResetNotification").Replace("[LoginId]", LoginIdText);

                                                _regionManager.RequestNavigate(RegionNames.MAIN_REGION, new Uri("ViewNotifications", UriKind.Relative));
                                            }
                                            else
                                            {
                                                Logging.LogLoginMethodParameterNull(_logger, resetMethodNamespace, 1, LoginIdText);
                                                SecurityAnswerState = FieldState.InvalidField;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                                            Logging.LogLoginException(_logger, ex);
                                        }

                                        Logging.LogLoginEndMethod(_logger, resetMethodNamespace, LoginIdText);
                                    });
                                    #endregion
                                }
                                else
                                {
                                    Logging.LogLoginMethodParameterNull(_logger, methodNamespace, 1, LoginIdText);
                                    LoginIdState = FieldState.InvalidField;
                                }
                            }
                            catch (Exception ex)
                            {
                                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                                Logging.LogLoginException(_logger, ex);
                            }

                            Logging.LogLoginEndMethod(_logger, methodNamespace, LoginIdText);
                        });
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                Logging.LogLoginException(_logger, ex);
            }
        }
Example #2
0
        /// <summary>
        /// Validate Login Credentials
        /// </summary>
        /// <returns>True/False</returns>
        private bool CredentialValidation()
        {
            bool credentialValidation = MissingValidations();

            try
            {
                if (_manageLogins != null)
                {
                    if (credentialValidation)
                    {
                        #region GetUser Service Call
                        _manageLogins.GetUser(LoginIdText, false, (user) =>
                        {
                            string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);
                            Logging.LogLoginBeginMethod(_logger, methodNamespace, LoginIdText);

                            try
                            {
                                if (user != null)
                                {
                                    Logging.LogLoginMethodParameter(_logger, methodNamespace, user, 1, LoginIdText);

                                    #region GetRolesForUser Service Call
                                    _manageLogins.GetRolesForUser(user.UserName, (userRoles) =>
                                    {
                                        string userRolesMethodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);
                                        Logging.LogLoginBeginMethod(_logger, userRolesMethodNamespace, LoginIdText);

                                        try
                                        {
                                            if (userRoles != null)
                                            {
                                                Logging.LogLoginMethodParameter(_logger, userRolesMethodNamespace, userRoles, 1, _loginIdText);
                                                UserRoles = userRoles;

                                                #region ValidateUser Service Call
                                                _manageLogins.ValidateUser(LoginIdText, PasswordText, (result) =>
                                                {
                                                    string userValidationmethodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);
                                                    Logging.LogLoginBeginMethod(_logger, userValidationmethodNamespace, LoginIdText);

                                                    try
                                                    {
                                                        if (result != null)
                                                        {
                                                            Logging.LogLoginMethodParameter(_logger, userValidationmethodNamespace, result, 1, _loginIdText);
                                                            if ((bool)result)
                                                            {
                                                                LoadModule();
                                                            }
                                                            else
                                                            {
                                                                if (!user.IsApproved)
                                                                {
                                                                    Logging.LogAccountInactiveLoginAttempt(_logger, LoginIdText);
                                                                    LoginIdState  = FieldState.LoginUnapproved;
                                                                    PasswordState = FieldState.LoginUnapproved;
                                                                }
                                                                else if (user.IsLockedOut)
                                                                {
                                                                    Logging.LogAccountLockedLoginAttempt(_logger, LoginIdText);
                                                                    LoginIdState  = FieldState.LoginLocked;
                                                                    PasswordState = FieldState.LoginLocked;
                                                                }
                                                                else
                                                                {
                                                                    Logging.LogAccountInvalidLoginAttempt(_logger, LoginIdText);
                                                                    LoginIdState  = FieldState.InvalidField;
                                                                    PasswordState = FieldState.InvalidField;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Logging.LogLoginMethodParameterNull(_logger, userValidationmethodNamespace, 1, LoginIdText);
                                                            LoginIdState  = FieldState.InvalidField;
                                                            PasswordState = FieldState.InvalidField;
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                                                        Logging.LogLoginException(_logger, ex);
                                                    }

                                                    Logging.LogLoginEndMethod(_logger, userValidationmethodNamespace, LoginIdText);
                                                });
                                                #endregion
                                            }
                                            else
                                            {
                                                Logging.LogLoginMethodParameterNull(_logger, userRolesMethodNamespace, 1, LoginIdText);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                                            Logging.LogLoginException(_logger, ex);
                                        }
                                        Logging.LogLoginEndMethod(_logger, userRolesMethodNamespace, LoginIdText);
                                    });
                                    #endregion
                                }
                                else
                                {
                                    Logging.LogLoginMethodParameterNull(_logger, methodNamespace, 1, LoginIdText);
                                    LoginIdState  = FieldState.InvalidField;
                                    PasswordState = FieldState.InvalidField;
                                }
                            }
                            catch (Exception ex)
                            {
                                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                                Logging.LogLoginException(_logger, ex);
                            }
                            Logging.LogLoginEndMethod(_logger, methodNamespace, LoginIdText);
                        });
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                Logging.LogLoginException(_logger, ex);
            }

            credentialValidation = LoginIdState == FieldState.ValidField && PasswordState == FieldState.ValidField;
            return(credentialValidation);
        }