public ForgotPasswordResetResult ForgotPassword(ForgotPasswordModel model) { var userProfile = _clientAppRepository.GetUser(model.Email); if (userProfile == null) { return(ForgotPasswordResetResult.BadEmail(model.Email)); } return(SendEmail(model, (email, confirmationSecret) => _emailService.SendForgotPasswordEmail(email, confirmationSecret))); }
public async Task <ForgotPasswordResetResult> ForgotPassword(ForgotPasswordModel model) { var validationResult = ValidateForgotModel(model); if (validationResult != null) { return(validationResult); } var userExists = await _identityProvider.VerifyUserExists(model.Email); if (!userExists) { return(ForgotPasswordResetResult.BadEmail(model.Email)); } return(await SendEmail( model, (email, confirmationSecret) => _emailService.SendForgotPasswordEmail(email, confirmationSecret))); }
public async Task <ForgotPasswordResetResult> ResendConfirmationAsync(ForgotPasswordModel model) { var userEmail = model.Email; var isVerifiedUser = await _identityProvider.VerifyUserExists(userEmail); if (!isVerifiedUser) { return(ForgotPasswordResetResult.BadEmail(userEmail)); } var isConfirmed = await _identityProvider.VerifyUserEmailConfirmed(userEmail); if (isConfirmed) { var message = string.Format( "The account with email address '{0}' has already been confirmed. Use the password reset if the password has been lost.", userEmail); return(new ForgotPasswordResetResult { Success = false, Message = message }); } var secret = await _identityProvider.GenerateEmailConfirmationToken(userEmail); try { _emailService.SendConfirmationEmail(userEmail, secret); } catch (Exception e) { _log.Error("SendEmail", e); return(EmailDown <ForgotPasswordResetResult>()); } return(ForgotPasswordResetResult.Successful); }
public async Task <ForgotPasswordResetResult> ResendConfirmationAsync(ForgotPasswordModel model) { var userName = model.Email; var badUserName = !WebSecurity.UserExists(userName); if (badUserName) { return(ForgotPasswordResetResult.BadEmail(userName)); } var isConfirmed = WebSecurity.IsConfirmed(userName); if (isConfirmed) { var message = string.Format( "The account with email address '{0}' has already been confirmed. Use the password reset if the password has been lost.", userName); return(new ForgotPasswordResetResult { Success = false, Message = message }); } var secret = await _clientAppRepository.GetTokenFromUserNameAsync(userName); try { _emailService.SendConfirmationEmail(userName, secret); } catch (Exception e) { _log.Error("SendEmail", e); return(EmailDown <ForgotPasswordResetResult>()); } return(ForgotPasswordResetResult.Successful); }