コード例 #1
0
ファイル: UserTest.cs プロジェクト: franknew/RiskMgr
        public void TestUserChangePassword()
        {
            bll.ChangePassword(new ChangePasswordUpdateForm
            {
                UserID      = defaultID,
                OldPassword = defaultID,
                NewPassword = "******",
            });
            var list = dao.Query(new UserQueryForm {
                ID = defaultID
            });

            Assert.AreEqual("changed1", list[0].Password);
        }
コード例 #2
0
        protected override void PostBack()
        {
            string password1 = RequestHelper.GetForm <string>("UserPassword1");
            string password2 = RequestHelper.GetForm <string>("UserPassword2");

            if (string.IsNullOrEmpty(password1) || string.IsNullOrEmpty("password2"))
            {
                ScriptHelper.Alert("ÃÜÂë²»ÄÜΪ¿Õ");
            }
            if (password1 != password2)
            {
                ScriptHelper.Alert("Á½´ÎÃÜÂë²»Ò»ÖÂ");
            }
            string   str         = StringHelper.Password(RequestHelper.GetForm <string>("OldPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string   newPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword1"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            UserInfo info        = UserBLL.ReadUser(base.UserID);

            if (str == info.UserPassword)
            {
                UserBLL.ChangePassword(base.UserID, newPassword);
                ScriptHelper.Alert("ÃÜÂëÐ޸ijɹ¦", RequestHelper.RawUrl);
            }
            else
            {
                ScriptHelper.Alert("¾ÉÃÜÂë´íÎó", RequestHelper.RawUrl);
            }
        }
コード例 #3
0
        protected override void PostBack()
        {
            string oldPassword  = StringHelper.Password(RequestHelper.GetForm <string>("OldPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string newPassword  = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword1"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string newPassword2 = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword2"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);

            if (oldPassword != CurrentUser.UserPassword)
            {
                ScriptHelper.AlertFront("旧密码错误", RequestHelper.RawUrl);
            }
            else
            {
                if (string.IsNullOrEmpty(RequestHelper.GetForm <string>("UserPassword1")))
                {
                    ScriptHelper.AlertFront("请输入新密码", RequestHelper.RawUrl);
                }
                else
                {
                    if (!string.Equals(RequestHelper.GetForm <string>("UserPassword1"), RequestHelper.GetForm <string>("UserPassword2")))
                    {
                        ScriptHelper.AlertFront("确认密码与新密码不一致", RequestHelper.RawUrl);
                    }
                    else
                    {
                        UserBLL.ChangePassword(base.UserId, oldPassword, newPassword);
                        CurrentUser.UserPassword = newPassword;
                        ScriptHelper.AlertFront("密码修改成功", RequestHelper.RawUrl);
                    }
                }
            }
        }
コード例 #4
0
        public ActionResult UpdateUserPassword()
        {
            User user = new User();

            user.ID = UserBLL.Instance.CurrentUser.ID;
            UpdateModel <User>(user);
            bllUser.ChangePassword(user.ID, user.Password);
            return(RedirectToAction("../User/List"));
        }
コード例 #5
0
ファイル: ResetPassword.cs プロジェクト: xuefuruanjian/ems
        protected override void PostBack()
        {
            string newPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword1"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            int    id          = Convert.ToInt32(StringHelper.Decode(RequestHelper.GetForm <string>("CheckCode"), ShopConfig.ReadConfigInfo().SecureKey).Split(new char[] { '|' })[0]);

            UserBLL.ChangePassword(id, newPassword);
            UserBLL.ChangeUserSafeCode(id, string.Empty, RequestHelper.DateNow);
            this.result = "恭喜您,密码修改成功!";
            ResponseHelper.Redirect("/User/ResetPassword.aspx?Result=" + base.Server.UrlEncode(this.result));
        }
コード例 #6
0
ファイル: UserController.cs プロジェクト: zkg642/JXXZ
        public HttpResponseMessage ChangePassword(User user)
        {
            int result = bll.ChangePassword(user);
            HttpResponseMessage response = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(result.ToString())
            };

            return(response);
        }
コード例 #7
0
        protected void SubmitButton_Click(object sender, EventArgs E)
        {
            int queryString = RequestHelper.GetQueryString <int>("ID");

            if (queryString != -2147483648)
            {
                string newPassword = StringHelper.Password(this.NewPassword.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                UserBLL.ChangePassword(queryString, newPassword);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("ChangeUserPassword"), queryString);
                AdminBasePage.Alert(ShopLanguage.ReadLanguage("UpdateOK"), RequestHelper.RawUrl);
            }
        }
コード例 #8
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            string userPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword1"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string checkCode    = RequestHelper.GetForm <string>("CheckCode");
            string decode       = StringHelper.Decode(checkCode, ShopConfig.ReadConfigInfo().SecureKey);
            int    userID       = Convert.ToInt32(decode.Split('|')[0]);

            UserBLL.ChangePassword(userID, userPassword);
            UserBLL.ChangeUserSafeCode(userID, string.Empty, RequestHelper.DateNow);
            result = "恭喜您,密码修改成功!" + "&nbsp;&nbsp;点击<a href=\"/user/Login.html\" style=\"color: #1d7fd4\">\"使用新密码登录\"</a>";
            ResponseHelper.Redirect("/User/ResetPassword.html?Result=" + Server.UrlEncode(result));
        }
コード例 #9
0
        protected void SubmitButton_Click(object sender, EventArgs E)
        {
            int userID = RequestHelper.GetQueryString <int>("ID");

            if (userID != int.MinValue)
            {
                string newPassword = StringHelper.Password(NewPassword.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                UserBLL.ChangePassword(userID, newPassword);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("ChangeUserPassword"), userID);
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("UpdateOK"), RequestHelper.RawUrl);
            }
        }
コード例 #10
0
        private void ChangeUserPassword()
        {
            int    userID      = RequestHelper.GetQueryString <int>("UserID");
            string newPassword = RequestHelper.GetForm <string>("UserPassword1");

            if (userID > 0)
            {
                newPassword = StringHelper.Password(newPassword, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                UserBLL.ChangePassword(userID, newPassword);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("ChangeUserPassword"), userID);
                ScriptHelper.Alert(ShopLanguage.ReadLanguage("UpdatePasswordOK"));
            }
        }
コード例 #11
0
        protected override void PostBack()
        {
            step = RequestHelper.GetForm <int>("step");
            string userName = StringHelper.AddSafe(RequestHelper.GetForm <string>("name"));

            if (string.IsNullOrEmpty(userName))
            {
                ResponseHelper.Redirect("/mobile/user/findpassword.html?step=1&msg=您输入的账户名不存在,请重新输入。");
            }

            user = UserBLL.Read(userName);
            if (user.Id < 1)
            {
                ResponseHelper.Redirect("/mobile/user/findpassword.html?step=1&msg=您输入的账户名不存在,请重新输入。");
            }

            //提交“填写帐户名”步骤
            if (step <= 1)
            {
                ResponseHelper.Redirect("/mobile/user/findpassword.html?step=2&u=" + user.UserName);
            }
            //提交“验证身份”步骤
            if (step == 2)
            {
                string   code   = StringHelper.AddSafe(RequestHelper.GetForm <string>("code"));
                string[] verify = StringHelper.Decode(CookiesHelper.ReadCookieValue("verify"), "sms").Split('|');
                if (verify.Length != 2 || userName != verify[0] || code != verify[1])
                {
                    ResponseHelper.Redirect("/mobile/user/findpassword.html?step=2&u=" + user.UserName + "&msg=您输入的短信验证码有误,请重新获取。");
                }

                ResponseHelper.Redirect("/mobile/user/findpassword.html?step=3&u=" + user.UserName);
            }
            //提交“设置新密码”步骤
            if (step == 3)
            {
                string   code   = StringHelper.AddSafe(RequestHelper.GetForm <string>("code"));
                string[] verify = StringHelper.Decode(CookiesHelper.ReadCookieValue("verify"), "sms").Split('|');
                if (verify.Length != 2 || userName != verify[0] || code != verify[1])
                {
                    ResponseHelper.Redirect("/mobile/user/findpassword.html?step=2&u=" + user.UserName + "&msg=您输入的短信验证码有误,请重新获取。");
                }

                string newPassword = StringHelper.Password(RequestHelper.GetForm <string>("password"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                UserBLL.ChangePassword(user.Id, newPassword);
                ResponseHelper.Redirect("/mobile/user/findpassword.html?step=4");
            }
        }
コード例 #12
0
        protected override void PostBack()
        {
            string oldPassword = StringHelper.Password(RequestHelper.GetForm <string>("OldPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string newPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword1"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);

            if (oldPassword == CurrentUser.UserPassword)
            {
                UserBLL.ChangePassword(base.UserId, oldPassword, newPassword);
                CurrentUser.UserPassword = newPassword;
                ScriptHelper.AlertFront("密码修改成功", RequestHelper.RawUrl);
            }
            else
            {
                ScriptHelper.AlertFront("旧密码错误", RequestHelper.RawUrl);
            }
        }
コード例 #13
0
        protected void btnChangePwd_Click(object sender, EventArgs e)
        {
            string oldPassword = Encryption.Encrypt(txtOldPwd.Text.Trim());
            string newPassword = Encryption.Encrypt(txtNewPwd.Text.Trim());

            IUser user = new UserEntity();

            user.Id          = _userId;
            user.Password    = oldPassword;
            user.NewPassword = newPassword;
            IActionResult result = UserBLL.ChangePassword(user);

            if (result.HasMessage)
            {
                Session.Abandon();
                Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script>javascript:alert('" + ResourceManager.GetStringWithoutName("R00032") + "');window.location.href='../Login.aspx'</script>");
            }
        }
コード例 #14
0
        public ActionResult ChangePassword(ProfileManagementModels.ChangePasswordSectionViewModel model)
        {
            try
            {
                int userID = UserLoginData.GetSessionID(Session["UserLoggedIn"]);
                if (ModelState.IsValid)
                {
                    userBLL.ChangePassword(userID, model.CurrentPassword, model.NewPassword);
                    return(RedirectToAction("ProfileManagement"));
                }

                return(View("ProfileManagement", new ProfileManagementModels(userBLL.GetUserInformation(userID), model)));
            }
            catch (Exception ex)
            {
                return(this.ManageException(ex, "ProfileManagement"));
            }
        }
コード例 #15
0
        private void btnxChangePassword_Click(object sender, EventArgs e)
        {
            string            usernameChange = this.username;
            frmChangePassword frmChangePwd   = new frmChangePassword();

            frmChangePwd.Username = usernameChange;
            frmChangePwd.ShowDialog();
            this.newPassword = frmChangePwd.NewPassword;

            if (frmChangePwd.CheckSave == true)
            {
                UserBLL userBLL = new UserBLL();
                bool    result  = userBLL.ChangePassword(this.username, this.newPassword);
                if (result == true)
                {
                    MessageBox.Show("Đổi mật khẩu Tài khoản Username = "******" thành công !!!", "ĐỔI MẬT KHẨU THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
コード例 #16
0
        private void BtnUpdatePassword_Click(object sender, EventArgs e)
        {
            try
            {
                if (FormLoggedUser.Role.UserRoleId == 2)
                {
                    MessageBox.Show("You don't have permision to change passwords", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    usrbll.ChangePassword(usr.UserID, Sec.Hash(txtUsernameChangePassword.Text, txtPasswordChangePassword.Text), FormLoggedUser.Id);
                    this.Close();
                }
            }

            catch (Exception)
            {
                throw;
            }
        }
コード例 #17
0
        protected void BtnChange_Clik(object sender, EventArgs e)
        {
            try
            {
                UserBLL _userBll = new UserBLL();

                //int status = _userBll.getCurrentStatusBy(((SessionUser)Session["SessionUser"]).UserId, txtCurrentPass.Text);
                if (txtCurrentPass.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Password Not Found')", true);
                    return;
                }
                else
                {
                    //string UserID = ((SessionUser)Session["SessionUser"]).UserId.ToString();
                    //string NewPassword = txtNewPass.Text.ToString();
                    string ConfPassword = txtConfirmPass.Text.ToString();
                    //if (NewPassword != ConfPassword)
                    //{
                    //    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('These passwords don't match. Try again?')", true);
                    //}

                    tbl_UserPassword _userPassword = new tbl_UserPassword();
                    _userPassword.UserID   = Guid.Parse(drpUserName.SelectedValue);
                    _userPassword.Password = ConfPassword;
                    int result = _userBll.ChangePassword(_userPassword);
                    if (result == 1)
                    {
                        drpUserName.ClearSelection();
                        txtCurrentPass.Text = "";
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Password Change Successfully.')", true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #18
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string newPwd = txtNewPwd.Text.Trim();

            if (newPwd == "")
            {
                MessageBox.Show("新密码不能为空");
                return;
            }
            if (MessageBox.Show("是否修改密码?", "密码修改", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (userBLL.ChangePassword(GlobalVariable.LoginUserInfo.id, newPwd))
                {
                    MessageBox.Show("密码修改成功");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("密码修改失败");
                }
            }
        }
コード例 #19
0
        protected void BtnChange_Clik(object sender, EventArgs e)
        {
            try
            {
                UserBLL _userBll = new UserBLL();

                int status = _userBll.getCurrentStatusBy(((SessionUser)Session["SessionUser"]).UserId, txtCurrentPass.Text);
                if (status == 1)
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('your Current Password is not Match.')", true);
                }
                else
                {
                    string UserID       = ((SessionUser)Session["SessionUser"]).UserId.ToString();
                    string NewPassword  = txtNewPass.Text.ToString();
                    string ConfPassword = txtConfirmPass.Text.ToString();
                    if (NewPassword != ConfPassword)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('These passwords don't match. Try again?')", true);
                    }
                    else
                    {
                        tbl_UserPassword _userPassword = new tbl_UserPassword();
                        _userPassword.UserID   = ((SessionUser)Session["SessionUser"]).UserId;
                        _userPassword.Password = ConfPassword;
                        int result = _userBll.ChangePassword(_userPassword);
                        if (result == 1)
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Password Change Successfully.')", true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #20
0
        public MResultModel ChangePassword(EditPasswordModel inputM)
        {
            MResultModel resM;

            try
            {
                _userBLL.ChangePassword(inputM.ID, inputM.OldPassword, inputM.NewPassword);
                resM = MResultModel.GetSuccessResultM("修改成功");
            }
            catch (ApplicationException ex)
            {
                resM = MResultModel.GetFailResultM(ex.Message);
            }
            catch (ArgumentNullException ex)
            {
                resM = MResultModel.GetFailResultM(ex.Message);
            }
            catch (ArgumentException ex)
            {
                resM = MResultModel.GetFailResultM(ex.Message);
            }
            return(resM);
        }
コード例 #21
0
 public bool ChangePassword(ChangePasswordUpdateForm form)
 {
     return(bll.ChangePassword(form));
 }
コード例 #22
0
ファイル: NewPass.aspx.cs プロジェクト: bmishra12/SHIPNPR
        protected void ChangePasswordCommand(object sender, EventArgs e)
        {
            //TODO: Validation to be replaced with ProxyValidator
            Page.Validate("ChangePasswordGroup");
            if (Page.IsValid)
            {
                //IMPORTANT! IMPORTANT! IMPORTANT!
                //NOTE: NO MATTER POSTBACK OR NOT, WE MUST VALIDATE THE TOKEN, EMAIL - FOR SECURITY REASONS.
                //OTHERWISE MANIPULATED OR ARTIFICIALLY CREATED POSTBACKS CAN HELP RESET PASSWORD.
                if (!UserBLL.IsPasswordResetTokenValid(Token, UserName))
                {
                    DisplayMessage("Sorry,", "An error occured. Your action was not recognized. Please contact support center if you need further assistance.");
                }

                string ErrorMessage;
                int?   UserId = UserBLL.GetUserIdForUserName(UserName);
                if (UserId.HasValue)
                {
                    //sammit-start
                    if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                        return;
                    }

                    UserProfile userProf = UserBLL.GetUserProfile((int)UserId);
                    UserAccount userAcc  = UserBLL.GetUserAccount((int)UserId);

                    if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), userProf.FirstName.Trim().ToLower(), userProf.LastName.Trim().ToLower(), userProf.MiddleName.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                        return;
                    }

                    if (PasswordValidation.DoesPassWordContainsEmail(userAcc.PrimaryEmail.Trim().ToLower(), Password.Text.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                        return;
                    }

                    if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                        return;
                    }
                    //sammit-end

                    //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                    //{
                    if (UserBLL.ChangePassword(UserId.Value, Password.Text.Trim(), out ErrorMessage))
                    {
                        if (!SendEmailToUserAboutPasswordChange())
                        {
                            DisplayMessage("Sorry. We were unable to complete the password change because we were unable to send confirmation email to your email address on record. If the problem persists, please contact support.", true);
                            return;
                        }

                        //DisplayMessage("Your password has been changed successfully. You may login with your new password any time.", false);
                        DisplayMessage("Success!", "Your password has been successfully changed.  You may login any time using the new password. <br> <br><a href='https://shipnpr.shiptalk.org/default.aspx'> Click here to login </a> ");
                        PasswordChangePanel.Visible = false;
                        //scope.Complete();
                    }
                    else

                    {
                        // DisplayMessage("Sorry. Unable to change password. Please contact support for assistance.", false);

                        //sammit show the error message
                        DisplayMessage(ErrorMessage, true);
                        return;
                    }
                    //}
                }
                else
                {
                    DisplayMessage("Sorry. Unable to change password. Please contact support for assistance.", false);
                }
            }
        }
コード例 #23
0
        public async Task <IActionResult> ChangePasswordJson(ChangePasswordParam entity)
        {
            TData <long> obj = await userBLL.ChangePassword(entity);

            return(Json(obj));
        }
コード例 #24
0
ファイル: FindPassword.cs プロジェクト: xuefuruanjian/ems
        protected override void PostBack()
        {
            string userName = StringHelper.SearchSafe(RequestHelper.GetForm <string>("UserName"));
            //string email = StringHelper.SearchSafe(RequestHelper.GetForm<string>("Email"));
            //string form = RequestHelper.GetForm<string>("SafeCode");
            string mobile = StringHelper.SearchSafe(RequestHelper.GetForm <string>("phone"));
            string code   = StringHelper.SearchSafe(RequestHelper.GetForm <string>("inputmovecode"));

            //int id = 0;
            if (userName == string.Empty)
            {
                this.errorMessage = "用户名不能为空";
            }
            if (string.IsNullOrEmpty(mobile))
            {
                this.errorMessage = "手机号码不能为空";
            }
            if (this.errorMessage == string.Empty)
            {
                //id = UserBLL.CheckUserName(userName);
                //if (id == 0)
                //{
                //    this.errorMessage = "不存在该用户名";
                //}
                UserSearchInfo userSearch = new UserSearchInfo();
                userSearch.Mobile   = mobile;
                userSearch.UserName = UserName;
                if (UserBLL.SearchUserList(userSearch).Count <= 0)
                {
                    this.errorMessage = "不存在该用户名";
                }
            }

            if (this.errorMessage == string.Empty)
            {
                bool IsSend = false;
                //从Cookies中读取验证码并解密
                string SrcCheckCode = StringHelper.Decode(CookiesHelper.ReadCookieValue("SMSCheckCode"), "SMS");

                //如果验证码值不为空(cookies的有效期只有几分钟)
                if (!string.IsNullOrEmpty(SrcCheckCode))
                {
                    if (SrcCheckCode == code)
                    {
                        IsSend = true;
                    }
                }
                else
                {
                    int TimeOutSeconds = 2 * 60;

                    SMSRecordInfo SMSRecordModel = SMSRecordBLL.ReadSMSRecord(mobile, code);
                    if (SMSRecordModel != null)
                    {
                        if ((DateTime.Now - SMSRecordModel.DataCreateDate).TotalSeconds <= TimeOutSeconds)
                        {
                            if (SMSRecordModel.VerCode == code)
                            {
                                IsSend = true;
                            }
                        }
                    }
                }

                if (!IsSend)
                {
                    this.errorMessage = "手机验证码错误!";
                }
            }
            //if ((this.errorMessage == string.Empty) && (email == string.Empty))
            //{
            //    this.errorMessage = "Email不能为空";
            //}
            //if ((this.errorMessage == string.Empty) && !UserBLL.CheckEmail(email))
            //{
            //    this.errorMessage = "不存在该Email";
            //}
            //if ((this.errorMessage == string.Empty) && (form.ToLower() != Cookies.Common.checkcode.ToLower()))
            //{
            //    this.errorMessage = "验证码错误";
            //}
            //if ((this.errorMessage == string.Empty) && (UserBLL.ReadUser(id).Email != email))
            //{
            //    this.errorMessage = "用户名和Email不匹配";
            //}
            if (this.errorMessage == string.Empty)
            {
                //string safeCode = Guid.NewGuid().ToString();
                //UserBLL.ChangeUserSafeCode(id, safeCode, RequestHelper.DateNow);
                //string newValue = "http://" + base.Request.ServerVariables["HTTP_HOST"] + "/User/ResetPassword.aspx?CheckCode=" + StringHelper.Encode(string.Concat(new object[] { id, "|", email, "|", userName, "|", safeCode }), ShopConfig.ReadConfigInfo().SecureKey);
                //EmailContentInfo info2 = EmailContentHelper.ReadSystemEmailContent("FindPassword");
                //EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                //emailSendRecord.Title = info2.EmailTitle;
                //emailSendRecord.Content = info2.EmailContent.Replace("$Url$", newValue);
                //emailSendRecord.IsSystem = 1;
                //emailSendRecord.EmailList = email;
                //emailSendRecord.IsStatisticsOpendEmail = 0;
                //emailSendRecord.SendStatus = 1;
                //emailSendRecord.AddDate = RequestHelper.DateNow;
                //emailSendRecord.SendDate = RequestHelper.DateNow;
                //emailSendRecord.ID = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord);
                //EmailSendRecordBLL.SendEmail(emailSendRecord);
                //this.result = "您的申请已提交,请登录邮箱重设你的密码!<a href=\"http://mail." + email.Substring(email.IndexOf("@") + 1) + "\"  target=\"_blank\">马上登录</a>";
                //ResponseHelper.Redirect("/User/FindPassword.aspx?Result=" + base.Server.UrlEncode(this.result));
                string userPassword = RequestHelper.GetForm <string>("password");

                UserSearchInfo userSearch = new UserSearchInfo();
                userSearch.Mobile        = mobile;
                userSearch.UserName      = userName;
                userSearch.StatusNoEqual = (int)UserState.Del;
                List <UserInfo> userList = UserBLL.SearchUserList(userSearch);
                if (userList.Count < 5)  //限制一下,安全第一,以免条件出错,把所有的都改了
                {
                    foreach (UserInfo user in userList)
                    {
                        user.UserPassword = StringHelper.Password(userPassword, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
                        UserBLL.ChangePassword(user.ID, user.UserPassword);
                    }
                }
                ScriptHelper.Alert("修改成功!", "/User/Login.aspx");
            }
            else
            {
                ResponseHelper.Redirect("/User/FindPassword.aspx?ErrorMessage=" + base.Server.UrlEncode(this.errorMessage));
            }
        }
コード例 #25
0
        protected void ChangePasswordCommand(object sender, EventArgs e)

        {
            //TODO: Validation to be replaced with ProxyValidator
            Page.Validate("ChangePasswordGroup");
            if (Page.IsValid)
            {
                //sammit-start

                UserProfile userProf = UserBLL.GetUserProfile(ShiptalkPrincipal.UserId);
                if (userProf.LastPasswordChangeDate != null && ((DateTime)userProf.LastPasswordChangeDate).Date == System.DateTime.Today)
                {
                    DisplayMessage("You are not allowed to change your password more than once in a day.", true);
                    return;
                }


                if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                    return;
                }


                UserAccount userAcc = UserBLL.GetUserAccount(ShiptalkPrincipal.UserId);
                EmailAddress = userAcc.PrimaryEmail;

                if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), userProf.FirstName.Trim().ToLower(), userProf.LastName.Trim().ToLower(), userProf.MiddleName.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                    return;
                }

                if (PasswordValidation.DoesPassWordContainsEmail(userAcc.PrimaryEmail.Trim().ToLower(), Password.Text.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                    return;
                }

                if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                    return;
                }
                //sammit-end

                //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                //{
                bool   DoCommit = false;
                string ErrorMessage;
                if (UserBLL.ChangePassword(ShiptalkPrincipal.UserId, Password.Text.Trim(), out ErrorMessage))
                {
                    if (SendEmailToUserAboutPasswordChange())
                    {
                        DoCommit = true;
                    }
                }
                else
                {
                    //sammit show the error message
                    DisplayMessage(ErrorMessage, true);
                    return;
                }

                if (DoCommit)
                {
                    //scope.Complete();
                    DisplayMessage("Success!", "Your password has been changed successfully.");
                    ChangePasswordPanel.Visible = false;
                }
                else
                {
                    DisplayMessage("Sorry. Unable to change your password. Please contact support for assistance.", false);
                }
                //}
            }
        }