public ActionResult ForgotPassword(string Email) { var otp = new OTPSimulation().MakeOTP(); string content = System.IO.File.ReadAllText(Server.MapPath("~/assets/Client/template/ResetPassword.html")); content = content.Replace("{{Password}}", otp); var EncryptingMD5Pw = Encryptor.MD5Hash(otp); new MailHelper().SendMail(Email, "Yêu cầu Reset Password", content); new AccountDAO().ResetPassWord(EncryptingMD5Pw, Email); ViewBag.Reset = otp; return(View()); }
public ActionResult ActivatingUser() { if (Session[CommonConstants.OTP_SESSION] == null) { if (Session[CommonConstants.USER_INFO_SESSION] != null) { var otp = new OTPSimulation().MakeOTP(); Session[CommonConstants.OTP_SESSION] = otp; var user = (Account)Session[CommonConstants.USER_INFO_SESSION]; string content = System.IO.File.ReadAllText(Server.MapPath("~/assets/Client/template/CodeActive.html")); content = content.Replace("{{Username}}", user.Username); content = content.Replace("{{CodeActive}}", otp); new MailHelper().SendMail(user.Email, "Mã kích hoạt tài khoản", content); } } return(View()); }
public ActionResult Register(RegisterModel account) { if (ModelState.IsValid) { var dao = new AccountDAO(); var EncryptingMD5Pw = Encryptor.MD5Hash(account.Password); account.Password = EncryptingMD5Pw; var user = new Account(); user.Username = account.Username; user.Password = account.Password; user.Name = account.Name; user.Phone = account.Phone; user.Address = account.Address; user.Email = account.Email; user.Status = false; user.CreateDate = DateTime.Now; user.Level = 0; var result = dao.Insert(user); if (result > 0) { var otp = new OTPSimulation().MakeOTP(); Session[CommonConstants.OTP_SESSION] = otp; Session.Add(CommonConstants.USER_INFO_SESSION, user); string content = System.IO.File.ReadAllText(Server.MapPath("~/assets/Client/template/CodeActive.html")); content = content.Replace("{{Username}}", user.Username); content = content.Replace("{{CodeActive}}", otp); new MailHelper().SendMail(user.Email, "Mã kích hoạt tài khoản", content); account = new RegisterModel(); return(Redirect("/kich-hoat-tk")); } else { return(Redirect("/dang-ky-that-bai")); } } return(View(account)); }