示例#1
0
        public ActionResult Index(ForgotPassword forgotPassword)
        {
            var IsExist = IsEmailExist(forgotPassword.EmailId);

            if (!IsExist)
            {
                ModelState.AddModelError("EmailNotExists", "This email is not exists");
                return(View());
            }
            else
            {
                string msg  = "Please check your inbox for an email we just sent you with instructions for how to reset your password.";
                User   user = _unitOfWork.User.Get(x => x.Email == forgotPassword.EmailId).FirstOrDefault();

                string OTP_Password = EncryptPassword.OPTPassword();
                user.ActivetionCode = Guid.NewGuid();
                user.OTP            = OTP_Password;
                _unitOfWork.User.Update(user);
                _unitOfWork.Complete();
                _unitOfWork.Dispose();
                UserRepository userRepository   = new UserRepository(new AutoSolutionContext());
                var            email            = user.Email;
                var            activationCode   = user.ActivetionCode;
                var            VerificationLink = "/ForgotPassword/ChangePassword/" + activationCode;
                var            link             = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, VerificationLink);
                UserEmailUtility.ForgetPasswordEmailToUser(email, link, OTP_Password);
                ViewBag.msg = msg;
                return(View());
            }
        }