예제 #1
0
        public ActionResult ForgotPassword(string ACCOUNT_Email)
        {
            if (ACCOUNT_Email != null)
            {
                var dao = new LoginDAO();
                if (dao.CheckEmail(ACCOUNT_Email))
                {
                    int    tokenkey = dao.RandomNumber(100000, 999999);
                    string content  = System.IO.File.ReadAllText(Server.MapPath("~/Views/templates/ForgotPassword.html"));

                    content = content.Replace("{{FullName}}", dao.GetByEmail(ACCOUNT_Email).ACCOUNT_Name);
                    content = content.Replace("{{tokenkey}}", Convert.ToString(tokenkey));
                    new MailHelper().SendMail(ACCOUNT_Email, "University Magazine", content, "Reset Password");

                    Session.Add(CommonConstants.SESSION_KEY, dao.GetToken(ACCOUNT_Email, dao.GetMD5(Convert.ToString(tokenkey))));
                    Session.Timeout = 5;

                    return(RedirectToAction("RecoverPassword", "Login", new { @email = ACCOUNT_Email }));
                }
                else
                {
                    SetAlert("Email does not exist!", "warning");
                }
            }
            return(View());
        }