/// <summary> /// 发送重置密码邮件 /// </summary> protected void btnFindPassWord_Click(object sender, EventArgs e) { this.btnFindPassWord.Enabled = false; string strUserName = Request.Form["txtUserName"]; string strEmail = Request.Form["txtContactEmail"]; string errMessage = ""; #region 页面验证 if (string.IsNullOrEmpty(strUserName)) { errMessage += "登录用户名不能为空!\\n"; } if (string.IsNullOrEmpty(strEmail)) { errMessage += "邮箱地址不能为空!\\n"; } else { if (!EyouSoft.Common.Function.StringValidate.IsEmail(strEmail)) { errMessage += "请输入正确的Email地址!\\n"; } else { if (!isExitEmail(strUserName, strEmail)) { errMessage += "Email与该用户不匹配!!\\n"; } } } #endregion if (errMessage != "") { EyouSoft.Common.Function.MessageBox.Show(this.Page, errMessage); return; } else { //SSO票据=DES加密(新字符串); string token = UpdateUserPwd.EncodeToken(UpdateUserPwd.GenerateToken(strUserName)); string findPwdLink = Domain.UserPublicCenter + "/Register/SetPassWord.aspx?s=" + token; //发送邮件成功 if (EyouSoft.Common.Email.ReminderEmailHelper.SendUpdatePasswordEmail(strEmail, findPwdLink, Domain.UserPublicCenter + "/Register/FindPassWord.aspx")) { Response.Redirect("/Register/FindPassWord.aspx?SendToEmail=1"); } } }
protected void btnSetPassWord_Click(object sender, EventArgs e) { string UserName = Server.UrlDecode(Request.Form["txtUserName"]); if (String.IsNullOrEmpty(UserName)) { EyouSoft.Common.Function.MessageBox.Show(this.Page, "用户名不能为空"); return; } //验证所填用户名是否是从邮箱点过来需要修改密码的用户名 int errorCode; bool isValid = false; try { isValid = UpdateUserPwd.IsTokenValid(UpdateUserPwd.DecodeToken(Request.QueryString["s"]), UserName, out errorCode); } catch (System.Exception) { isValid = false; errorCode = 3; } if (isValid) { string NewPwd = Server.UrlDecode(Request.Form["txtPassWord"]); if (UserName != "" && NewPwd != "") { EyouSoft.Model.CompanyStructure.CompanyUser Model = EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance().GetModelByUserName(UserName); if (Model != null) { string UserId = Model.ID; EyouSoft.Model.CompanyStructure.PassWord PwdModel = new EyouSoft.Model.CompanyStructure.PassWord(); PwdModel.NoEncryptPassword = NewPwd; if (EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance().UpdatePassWord(UserId, PwdModel)) { this.tr_TrueSetPwd.Visible = true; this.tr_SetPassWord.Visible = false; } PwdModel = null; } Model = null; } } else { if (errorCode == 1) { EyouSoft.Common.Function.MessageBox.Show(this.Page, "请填写正确的用户名"); return; } else if (errorCode == 2) { this.tr_LinkOut.Visible = true; this.tr_SetPassWord.Visible = false; } else { this.tr_FalseSetPwd.Visible = true; this.tr_SetPassWord.Visible = false; } } }