Beispiel #1
0
 public static bool CheckPassword(string pwd, string storedPwd)
 {
     pwd = GlobalSettings.EncodePassword(pwd);
     if (GlobalSettings.IsNullOrEmpty(pwd))
     {
         return(false);
     }
     return(pwd.Equals(storedPwd, StringComparison.CurrentCulture));
 }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        User u = Profile.AccountInfo;

        if (GlobalSettings.EncodePassword(txtOldAnswer.Text.Trim()) != u.PasswordAnswer)
        {
            base.ExecuteJs("msg('原始密码提示答案错误,无法完成修改!')", false);
        }
        else
        {
            u.PasswordAnswer = txtNewAnswer.Text.Trim();
            u.Password       = string.Empty;
            if (Users.UpdateUser(u))
            {
                base.ExecuteJs("msg('成功修改密码提示答案!')", false);
            }
            else
            {
                base.ExecuteJs("msg('修改密码提示答案失败!')", false);
            }
        }
    }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            if (!ValidateParameter(ref password, true, true, false, 0))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            if (passwordStrengthRegularExpression != null)
            {
                if (!Regex.IsMatch(password, passwordStrengthRegularExpression))
                {
                    status = MembershipCreateStatus.InvalidPassword;
                    return(null);
                }
            }

            if (password.Length < minRequiredPasswordLength)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            string pass = GlobalSettings.EncodePassword(password, (PasswordFormat)(int)passwordFormat, hashAlgorithmType);

            if (pass.Length > 128)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            if (!ValidateParameter(ref username, true, true, true, 255))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return(null);
            }

            if (!ValidateParameter(ref email, RequiresUniqueEmail, RequiresUniqueEmail, false, 128))
            {
                status = MembershipCreateStatus.InvalidEmail;
                return(null);
            }

            if (!ValidateParameter(ref passwordQuestion, RequiresQuestionAndAnswer, true, false, 255))
            {
                status = MembershipCreateStatus.InvalidQuestion;
                return(null);
            }

            if (!ValidateParameter(ref passwordAnswer, RequiresQuestionAndAnswer, true, false, 128))
            {
                status = MembershipCreateStatus.InvalidAnswer;
                return(null);
            }

            status = MembershipCreateStatus.UserRejected;
            try
            {
                DateTime dt = DateTime.Now;
                status = MembershipCreateStatus.Success;
                int uid = 0;
                status = Users.QuickCreate(username, password, email, passwordQuestion, passwordAnswer, isApproved, out uid);
                return(new MembershipUser(this.Name, username, uid, email, passwordQuestion, null, isApproved, false, dt, dt, dt, dt, DateTime.MinValue));
            }
            catch (Exception)
            {
                if (status == MembershipCreateStatus.Success)
                {
                    status = MembershipCreateStatus.ProviderError;
                }
                return(null);
            }
        }