Esempio n. 1
0
        public async Task<ActionResult> RequestPasswordReset(PasswordResetRequestViewModel request, string returnUrl = "")
        {
            AuthManager.SignOut();

            if (!ModelState.IsValid)
            {
                return View(request);
            }
            // try to find user
            var user = await userManager.FindByNameAsync(request.EMail);

            if (user == null)
            {

                // if user was not found return form with error
                ModelState.AddModelError("", Resources.User.Strings.ErrorUserNotFound);
                return View(request);
            }

            // Generate token and send it to the user

            var token = userManager.GeneratePasswordResetToken(user.Id);

            // Send E-Mail

            var resetUrl = this.Url.Action(
                "ResetPassword",
                null,
                new
                {
                    userId = user.Id,
                    token = token,
                    returnUrl = returnUrl
                },
                Request.Url.Scheme
            );

            sendMail.SponsoringOrganization = user.SponsoringOrganization;
            sendMail.RequestPasswordReset(user, resetUrl);

            return View("RequestPasswordResetSent", request);
        }
Esempio n. 2
0
 public ActionResult RequestPasswordReset(string returnUrl = "")
 {
     PasswordResetRequestViewModel request = new PasswordResetRequestViewModel();
     return View(request);
 }