public static Tuple <Singular.Web.MessageType, String> ChangePassword(ChangeDetails details)
        {
            // Check for any business rule failures
            if (!details.CheckAllRules())
            {
                return(Tuple.Create(Singular.Web.MessageType.Validation, "Validation failed"));
            }

            // Check if the password meets complexity requirements
            Singular.Misc.Password.PasswordChecker passwordChecker = new Singular.Misc.Password.PasswordChecker(8, true, true, true, false, 1);
            if (!passwordChecker.CheckPassword(details.NewPassword))
            {
                return(Tuple.Create(Singular.Web.MessageType.Warning, passwordChecker.ErrorMessage));
            }

            // Attempt to change the user's password
            DataRow result = CommandProc.GetDataRow(
                "CmdProcs.cmdChangePassword",
                new string[] { "@UserID", "@OldPassword", "@NewPassword" },
                new object[] {
                Singular.Settings.CurrentUserID,
                OETWebSecurity.GetPasswordHash(details.OldPassword),
                OETWebSecurity.GetPasswordHash(details.NewPassword)
            });

            if (!(bool)result[0])
            {
                return(Tuple.Create(Singular.Web.MessageType.Warning, "The password you entered doesn't match your current password."));
            }
            else
            {
                return(Tuple.Create(Singular.Web.MessageType.Success, "Change Password Success."));
            }
        }
        public static Tuple <Singular.Web.MessageType, String> ChangePassword(ChangeDetails details)
        {
            // Check for any business rule failures
            if (!details.CheckAllRules())
            {
                return(Tuple.Create(Singular.Web.MessageType.Validation, "Validation failed"));
            }

            // Check if the password meets complexity requirements
            Singular.Misc.Password.PasswordChecker passwordChecker = new Singular.Misc.Password.PasswordChecker(8, true, true, true, false, 1);
            if (!passwordChecker.CheckPassword(details.NewPassword))
            {
                return(Tuple.Create(Singular.Web.MessageType.Warning, passwordChecker.ErrorMessage));
            }

            // Attempt to change the user's password
            int CheckOP = 0;

            if (details.OldPassword != "")
            {
                CheckOP = 1;
            }
            try
            {
                DataRow result = CommandProc.GetDataRow(
                    "CmdProcs.cmdChangePassword",
                    new string[] { "@UserID", "@OldPassword", "@NewPassword", "@CheckOldPassword" },
                    new object[] {
                    Singular.Settings.CurrentUserID,
                    MEWebSecurity.CurrentIdentity().FirstTimeLogin == false || MEWebSecurity.CurrentIdentity().ResetState == ResetState.MustResetPassword? MEWebSecurity.GetPasswordHash(details.OldPassword) : details.OldPassword,
                    MEWebSecurity.GetPasswordHash(details.NewPassword),
                    CheckOP
                });

                if (bool.Parse(result.ItemArray[0].ToString()) == true)
                {
                    if (MELib.Security.MEWebSecurity.CurrentIdentity().Roles.Contains("Users.ForgotPassword"))
                    {
                        MELib.Security.MEWebSecurity.CurrentIdentity().Roles.Remove("Users.ForgotPassword");
                    }

                    MEWebSecurity.CurrentIdentity().MarkNonFirstTimeLogin();
                    MEWebSecurity.CurrentIdentity().ChangedPassword();
                    return(Tuple.Create(Singular.Web.MessageType.Success, "Change Password Success."));
                }
                else
                {
                    return(Tuple.Create(Singular.Web.MessageType.Error, "Change Password Failed - Incorrect Temporary Password"));
                }
            }
            catch (Exception)
            {
                return(Tuple.Create(Singular.Web.MessageType.Error, "Change Password Failed - Please contact System Administrator"));

                throw;
            }
        }