public async Task <ActionResult> PForgotPassword(string username) { if (!string.IsNullOrEmpty(username)) { var aspUser = await _userManager.FindByNameAsync(username); if (aspUser == null || !(await _userManager.IsEmailConfirmedAsync(aspUser))) { this.AddNotification("Please your email or username is not valid or yet to be confirmed.", NotificationType.ERROR); return(RedirectToAction("login", "account")); } var userInfo = _userService.GetUser(aspUser.Id); ////Password Generator //string generatePassword; ////Password Requirements //var passwrule = _userManager.Options.Password; ////Generate Password for User //generatePassword = PasswordGenerator.CreateRandom(passwrule.RequiredLength, passwrule.RequireUppercase, passwrule.RequireDigit, passwrule.RequireLowercase); var code = await _userManager.GeneratePasswordResetTokenAsync(aspUser); var callbackUrl = Url.Action("ResetPassword", "Account", new { UserId = aspUser.Id, code }, protocol: Request.Scheme); await _mailService.SendPasswordResetEmail(aspUser.Email, aspUser.UserName, callbackUrl, 0); this.AddNotification("An email notification has been sent to your email box!", NotificationType.SUCCESS); return(RedirectToAction(nameof(ForgotPassword))); } this.AddNotification("Username cannot be empty", NotificationType.WARNING); return(RedirectToAction("login", "account")); }