Ejemplo n.º 1
0
 //
 // GET: /Mail/
 public EmailResult ResetPasswordVerificationEmail(RequestResetPasswordViewModel vm)
 {
     To.Add(vm.Email);
     From = AppConfigs.SiteEmail;
     Subject = "Xác nhận quên mật khẩu - Vuabep.vn";
     MessageEncoding = Encoding.Unicode;
     return Email("ResetPasswordVerificationEmail", vm);
 }
Ejemplo n.º 2
0
        public ActionResult RequestResetPassword(RequestResetPasswordViewModel vm)
        {
            if (ModelState.IsValid)
            {
                // Insert ResetPassword key into DB
                var tmp = string.Format("{0}{1}", Guid.NewGuid(), Guid.NewGuid());
                var resetPasswordKey = tmp.Replace("-", "");

                var feedback = _securityRepository.RequestResetPassword(vm.Email, resetPasswordKey);
                if (feedback.Success)
                {
                    // Send verification email
                    MailController mailController = new MailController();
                    vm.Username = feedback.Data.Username;
                    vm.ResetPasswordKey = resetPasswordKey;
                    vm.ResetPasswordLink = string.Format("http://{0}/account/resetpassword?key={1}", Request.Url.Authority,
                                                        resetPasswordKey);
                    try
                    {
                        mailController.ResetPasswordVerificationEmail(vm).Deliver();

                        return View("RequestPasswordSuccess");
                    }
                    catch
                    {
                        SetMessage("Có lỗi xảy ra. Hệ thống không thể gửi mail xác nhận quên mật khẩu cho bạn.", MessageType.Error);
                    }
                }
                else
                {
                    ModelState.AddModelError("", feedback.Message);
                }
            }

            return View(vm);
        }