예제 #1
0
        public IActionResult ForgotPassword(string email)
        {
            string resultCode = UserBus.ForgorPassword(email); // mail +"-"+chuỗi mã hoá: khi lấy ra thì slipt cái "-" rồi lấy chuỗi so khớp

            if (resultCode != null)
            {
                string link = "https://localhost:44307/home/changePW?pwId=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(resultCode));
                if (new SendMail(configuration).Send(email, "Change password", "Click the following link: " + link))
                {
                    TempData["Result"] = "0";
                    return(RedirectToAction("forgotpassword", "home"));
                }
                else
                {
                    ViewBag.Error = "[Network error please try again later]";
                    return(View());
                }
            }
            ViewBag.Error = "[Email invalid. Please check again]";
            return(View());
        }