public async Task <IActionResult> RequestPasswordReset(PasswordResetRequestViewModel model)
        {
            // Validates the received email address based on the view model
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Gets the user entity for the specified email address
            ApplicationUser user = await userManager.FindByEmailAsync(model.Email);

            if (user != null)
            {
                // Generates a password reset token for the user
                string token = await userManager.GeneratePasswordResetTokenAsync(user);

                // Prepares the URL of the password reset link (targets the "ResetPassword" action)
                // Fill in the name of your controller
                string resetUrl = Url.Action(nameof(PasswordResetController.PasswordReset), nameof(PasswordResetController), new { userId = user.Id, token }, Request.Scheme);

                // Creates and sends the password reset email to the user's address
                await messageService.SendEmailAsync(user.Email, "Password reset request",
                                                    $"To reset your account's password, click <a href=\"{resetUrl}\">here</a>");
            }

            // Displays a view asking the visitor to check their email and click the password reset link
            return(View("CheckYourEmail"));
        }
        public async Task <ActionResult> ForgotPassword(PasswordResetRequestViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var kullanici = await UserManager.FindByEmailAsync(model.Email);

            if (kullanici == null)
            {
                ModelState.AddModelError("", "Bu E-Posta Sistemde Kayıtlı Değil!");
                return(View(model));
            }
            else
            {
                string code = await UserManager.GeneratePasswordResetTokenAsync(kullanici.Id);

                var             callbackUrl = Url.Action("PasswordReset", "Account", new { email = kullanici.Email, userId = kullanici.Id, code = code }, protocol: Request.Url.Scheme);
                IdentityMessage msg         = new IdentityMessage();
                msg.Destination = kullanici.Email;
                msg.Body        = "Şifreni sıfırlama isteğini aldık, değerlendirdik ve uygun bulduk. İnsanlık hali, unutmak da var kaptırmak da, biliyoruz. Sıfırlama işlemi için <a href=\"" + callbackUrl + "\">şifremi sıfırla</a> linkine tıkla.";
                msg.Subject     = "NeYapsak Şifre Sıfırlama Servisi";
                mail.SendMail(msg);
                return(View("DisplayPasswordReset"));
            }
        }
        public async Task <IActionResult> PasswordResetRequestHandler(PasswordResetRequestViewModel requestViewModel)
        {
            var user = (await _userLogic.GetAll()).FirstOrDefault(x =>
                                                                  string.Equals(x.Email, requestViewModel.Email, StringComparison.OrdinalIgnoreCase) &&
                                                                  string.Equals(x.UserName, requestViewModel.Username, StringComparison.OrdinalIgnoreCase));

            if (user == null)
            {
                TempData["Error"] = "Failed to find the user";

                return(RedirectToAction("PasswordResetRequest"));
            }

            var token = await _userManager.GeneratePasswordResetTokenAsync(user);

            await _passwordResetLogic.SendPasswordResetEmail(user, token);

            TempData["Message"] = "Successfully sent the password reset email. Please check your email!";

            return(RedirectToAction("PasswordResetRequest"));
        }