public ActionResult RegisterUser(string userName, string userEmail, string password) { var checkUser = UserDataDapper.FindUser(userName); if (checkUser != null) { return(Json(new { success = false, error = "用户已存在!" })); } try { string token = Tools.GetMD5(EncryptionTools.Crypt(userName + userEmail)); EmailInfo email = new EmailInfo(); email.Body = $"Hi,{userName}. <br>欢迎您注册地图搜租房(woyaozufang.live),你的账号已经注册成功." + "<br/>为了保证您能正常体验网站服务,请点击下面的链接完成邮箱验证以激活账号." + $"<br><a href='https://woyaozufang.live/Account/Activated?activatedCode={token}'>https://woyaozufang.live/Account/Activate?activatedCode={token}</a> " + "<br>如果您以上链接无法点击,您可以将以上链接复制并粘贴到浏览器地址栏打开." + "<br>此信由系统自动发出,系统不接收回信,因此请勿直接回复。" + "<br>如果有其他问题咨询请发邮件到[email protected]."; email.Receiver = userEmail; email.Subject = "地图找租房-激活账号"; email.ReceiverName = userName; email.Send(); var user = new UserInfo(); user.UserName = userName; user.Password = password; user.Email = userEmail; user.ActivatedCode = token; UserDataDapper.InsertUser(user); return(Json(new { success = true, message = "注册成功!" })); } catch (Exception ex) { return(Json(new { success = false, error = ex.ToString() })); } }
public ActionResult RegisterUser(UIUserInfo uiUserInfo) { var bizUserInfo = new BizUserInfo(); bizUserInfo.UserEmail = uiUserInfo.UserEmail; bizUserInfo.UserLoginName = uiUserInfo.UserEmail; bizUserInfo.UserName = uiUserInfo.UserName; bizUserInfo.UserPassword = uiUserInfo.Password; bizUserInfo.UserPhone = uiUserInfo.Phone; bizUserInfo.UserQQ = uiUserInfo.QQ; bizUserInfo.UserInfoComment = uiUserInfo.UserInfoComment; string token = (uiUserInfo.UserEmail + uiUserInfo.UserName).ConvertToCiphertext(); bizUserInfo.ActivateAccountToken = token; bizUserInfo.AccountStatus = 0; var result = UserInfoBo.RegisterUser(bizUserInfo); if (result.IsSuccess) { var activateAccountEmailContent = BizConfigurationInfo.LoadByKey(Conts.ActivateAccountEmailContentKey).ConfigurationValue; EmailInfo activateAccountEmail = new EmailInfo(); activateAccountEmail.Receiver = uiUserInfo.UserEmail; activateAccountEmail.Subject = "激活WebBookmark账号"; activateAccountEmail.Body = string.Format(activateAccountEmailContent, token, token); activateAccountEmail.Send(); } return(Json(result)); }
public ActionResult SendRetrievePasswordEmail(string emailAccount) { try { var user = UserDataDapper.FindUser(emailAccount); var token = Tools.GetMD5(EncryptionTools.Crypt(user.UserName + user.Email + DateTime.Now.ToString())); EmailInfo email = new EmailInfo(); email.Body = $"Hi,{user.UserName}. <br>您正在通过注册邮箱找回密码,如果非本人操作,请勿继续." + "<br>请在24小时内点击以下链接重置密码:" + $"<br><a href='https://woyaozufang.live/Account/ModifyPassword?token={token}'>https://woyaozufang.live/Account/ModifyPassword?token={token}</a> " + "<br>如果您以上链接无法点击,您可以将以上链接复制并粘贴到浏览器地址栏打开." + "<br>此信由系统自动发出,系统不接收回信,因此请勿直接回复。" + "<br>如果有其他问题咨询请发邮件到[email protected]."; email.Receiver = user.Email; email.Subject = "地图找租房-找回密码"; email.ReceiverName = user.UserName; email.Send(); UserDataDapper.SaveRetrievePasswordToken(user.ID, token); return(Json(new { success = true })); } catch (Exception ex) { return(Json(new { success = false, error = ex.ToString() })); } }
public ActionResult SendRetrievePasswordEmail(string emailAccount) { BizResultInfo result = new BizResultInfo(); if (string.IsNullOrEmpty(emailAccount)) { result.IsSuccess = false; result.ErrorMessage = "邮箱地址不能为空。"; return(Json(result)); } result = UserInfoBo.GetUserInfoByLoginNameOrEmail(emailAccount); if (result.IsSuccess) { var retrievePasswordEmailContent = BizConfigurationInfo.LoadByKey(Conts.RetrievePasswordEmailContentKey).ConfigurationValue; var userInfo = result.Target as BizUserInfo; if (userInfo == null) { result.IsSuccess = false; result.ErrorMessage = "找不到对象了...可能这就是命吧。"; return(Json(result)); } string token = (userInfo.UserInfoID + userInfo.UserEmail + DateTime.Now).ConvertToCiphertext(); var retrievePasswordLog = new BizRetrievePasswordLog(); retrievePasswordLog.CreateTime = DateTime.Now; retrievePasswordLog.LogStatus = 0; retrievePasswordLog.Token = token; retrievePasswordLog.UserInfoID = userInfo.UserInfoID; retrievePasswordLog.LastTime = DateTime.Now; retrievePasswordLog.Save(); EmailInfo emailInfo = new EmailInfo(); emailInfo.Subject = "WebBookmark找回密码"; emailInfo.Body = string.Format(retrievePasswordEmailContent, token, token); emailInfo.Receiver = emailAccount; emailInfo.Send(); } result.IsSuccess = true; return(Json(result)); }
public ActionResult SaveStudentInfo(StudentInfo studentInfo) { try { studentInfo.CreateTime = DateTime.Now; var result = studentInfo.Save(); if (result) { EmailInfo email = new EmailInfo(); email.Receiver = studentInfo.QQNumber.Trim() + "@qq.com"; email.ReceiverName = studentInfo.StudentName; email.Subject = "IT培优招新报名成功!"; email.Body = "<p>报名成功!如有其他问题请回复此邮箱!</p>"; email.Send(); } return(Json(new { IsSuccess = result, SuccessMessage = "报名成功!" })); }catch (Exception ex) { return(Json(new { IsSuccess = false, Erroe = ex.ToString() })); } }