示例#1
0
 public ActionResult RetrievePassword(RetrievePasswordViewModel data)
 {
     //Users users = new Users();
     //if (users.RecoverPassword(data)) {
     //	TempData["RecoverSuccess"] = "<p>Your username and password have been sent to you by email.</p><p>When you have received your password, <a href='/login'>return to this page to login</a>.</p>";
     //	TempData["RecoverFail"] = "";
     //} else {
     //	TempData["RetrieveUserName"] = data.RetrieveUserName;
     //	TempData["RecoverSuccess"] = "";
     //	TempData["RecoverFail"] = "<p>We were unable to access your information. An alert containing the information you entered has been sent to the help desk.</p><p>If you need immediate assistance, email us at <a href='mailto:" + Global.SiteEmail + "'>" + Global.SiteEmail + "</a></p>";
     //}
     return(RedirectToAction("Index"));
 }
示例#2
0
        public ActionResult Retrieve()
        {
            RetrievePasswordViewModel retrievePassword = new RetrievePasswordViewModel();

            if (TempData["RetrieveUserName"] != null)
            {
                retrievePassword.RetrieveUserName = TempData["RetrieveUserName"].ToString();
            }
            if (TempData["RecoverSuccess"] != null)
            {
                retrievePassword.SuccessMessage = TempData["RecoverSuccess"].ToString();
            }
            if (TempData["RecoverFail"] != null)
            {
                retrievePassword.ErrorMessage = TempData["RecoverFail"].ToString();
            }
            return(PartialView("_RetrievePassword", retrievePassword));
        }
        public async Task <ActionResult> RetrievePassword(RetrievePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_RetrievePassword", model));
            }

            var user = UserManager.FindByEmail(model.Email);

            if (user != null)
            {
                var token = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                var url = Url.Action("ResetPassword", "Account", new { userId = user.Id, token }, RequestContext.URL.Scheme);

                await UserManager.SendEmailAsync(user.Id, ResHelper.GetString("DancingGoatMvc.PasswordReset.Email.Subject"),
                                                 String.Format(ResHelper.GetString("DancingGoatMvc.PasswordReset.Email.Body"), url));
            }

            return(Content(ResHelper.GetString("DancingGoatMvc.PasswordReset.EmailSent")));
        }
示例#4
0
        public async Task <ActionResult> RetrievePassword(RetrievePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_RetrievePassword", model));
            }

            var user = await userManager.FindByEmailAsync(model.Email);

            if (user != null)
            {
                var token = await userManager.GeneratePasswordResetTokenAsync(user);

                var url = Url.Action(nameof(ResetPassword), "Account", new { userId = user.Id, token }, RequestContext.URL.Scheme);

                await emailService.SendEmailAsync(user.Email, localizer["Request for changing your password"],
                                                  string.Format(localizer["You have submitted a request to change your password. " +
                                                                          "Please click <a href=\"{0}\">this link</a> to set a new password.<br/><br/> " +
                                                                          "If you did not submit the request please let us know."], url));
            }

            return(Content(localizer["If the email address is known to us, we'll send a password recovery link in a few minutes."]));
        }