示例#1
0
        public async Task <IActionResult> SendPassword(SendPasswordViewModel sendPasswordViewModel)
        {
            if (ModelState.IsValid)
            {
                AppUser user = await _userManager.FindByEmailAsync(sendPasswordViewModel.Email);

                if (user != null)
                {
                    string passwordResetToken = await _userManager.GeneratePasswordResetTokenAsync(user);

                    string passwordResetLink = Url.Action("ResetPasswordConfirm", "Home", new
                    {
                        userId = user.Id,
                        token  = passwordResetToken
                    }, HttpContext.Request.Scheme);

                    PasswordReset.PasswordResetSendEmail(link: passwordResetLink, emailAddress: sendPasswordViewModel.Email);
                    ViewBag.status = "Başarılı";
                }
                else
                {
                    ModelState.AddModelError("", "Kayıtlı email adresi bulunamamıştır.");
                    return(View(sendPasswordViewModel));
                }
            }
            else
            {
                ModelState.AddModelError("", "Kayıtlı email adresi bulunamamıştır.");
                return(View(sendPasswordViewModel));
            }
            return(View(sendPasswordViewModel));
        }