public async Task <PasswordResetResult> ResetPassword(PasswordResetModel model) { try { var validationResult = await ValidateResetModel(model); if (validationResult != null) { return(validationResult); } var user = await _identityProvider.FindUserByEmail(model.Email); if (user == null) { return(PasswordResetResult.BadUsername); } var resetSuccessful = await _identityProvider.ResetUserPassword(user.UserName, model.Password); if (!resetSuccessful) { return(PasswordResetResult.BadPassword); } return(PasswordResetResult.Successful); } catch (Exception e) { _log.Error("ResetPassword", e); return(DatabaseUnreachableResult <PasswordResetResult>()); } }