public async Task <IActionResult> Index(RecoverInputModel model)
        {
            if (ModelState.IsValid)
            {
                // Load user by email
                var email = model.Email.ToLower();

                // Check if user with same email exists
                var userAccount = await _userAccountService.LoadByEmailAsync(email);

                if (userAccount != null)
                {
                    await _userAccountService.SetResetPasswordVirificationKey(userAccount, model.ReturnUrl);

                    var args = new { Key = userAccount.VerificationKey };
                    await _emailService.SendEmailAsync(
                        IdentityBaseConstants.EmailTemplates.UserAccountRecover, userAccount.Email, new
                    {
                        ConfirmUrl = Url.Action("Confirm", "Recover", args, Request.Scheme),
                        CancelUrl  = Url.Action("Cancel", "Recover", args, Request.Scheme)
                    }
                        );

                    return(await this.RedirectToSuccessAsync(userAccount, model.ReturnUrl));
                }
                else
                {
                    ModelState.AddModelError("", "User is deactivated.");
                }
            }

            var vm = new RecoverViewModel(model);

            return(View(vm));
        }
Exemple #2
0
 public RecoverViewModel(RecoverInputModel other)
 {
     this.Email = other.Email;
 }