예제 #1
0
        public async Task <ActionResult> ForgotPassword(string email)
        {
            AppUser user = await _userManager.FindByEmailAsync(email);

            if (user == null)
            {
                ModelState.AddModelError("", GetErrorMessage.NullUser);
                return(View());
            }

            if (!string.IsNullOrWhiteSpace(email) && email.Contains("@"))
            {
                string code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);

                string callbackUrl = Url.Action("ResetPassword", "Account", new { code = code }, protocol: Request.Url.Scheme);
                _mailingRepository.ResetPasswordMail(user.Email, callbackUrl);
                return(View("ForgotPasswordConfirmation"));
            }
            ModelState.AddModelError("", GetErrorMessage.NoEmail);
            return(View());
        }