public async Task <IActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByEmailAsync(model.Email);

                if (user == null)
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return(RedirectToAction(nameof(ForgotPasswordConfirmation)));
                }

                // For more information on how to enable account confirmation and password reset please
                // visit https://go.microsoft.com/fwlink/?LinkID=532713
                var code = await _userManager.GeneratePasswordResetTokenAsync(user);

                var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme);
                await _emailSender.AddPendingEmail(model.Email, "Восстановление пароля",
                                                   $"Для восстановления перейдите по следующей ссылке: <a href='{callbackUrl}'>восстановить</a>");

                return(RedirectToAction(nameof(ForgotPasswordConfirmation)));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 2
0
 public static Task SendEmailInvitationAsync(this IEmailSender emailSender, string appUrl, string email, string userPassword)
 {
     return(emailSender.AddPendingEmail(email, "Вы были добавлены в систему",
                                        $"Для Вас создан аккаунт в <a href='{appUrl}'>{appUrl}</a>. Ваш временный пароль <b>{userPassword}<b>"));
 }