Skip to content

Commit

Permalink
Fix leaking information about non existing email in forgotten password
Browse files Browse the repository at this point in the history
  • Loading branch information
vknaisl committed Jan 22, 2024
1 parent 429b11f commit a1f9f4a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions wizard-server/src/Wizard/Service/User/UserService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,15 @@ changeUserPasswordByHash userUuid hash userPasswordDto =
resetUserPassword :: ActionKeyDTO ActionKeyType -> AppContextM ()
resetUserPassword reqDto =
runInTransaction $ do
user <- findUserByEmail reqDto.email
tenantUuid <- asks currentTenantUuid
actionKey <- createActionKey user.uuid ForgottenPasswordActionKey tenantUuid
catchError
(sendResetPasswordMail (toDTO user) actionKey.hash)
(\errMessage -> throwError $ GeneralServerError _ERROR_SERVICE_USER__RECOVERY_EMAIL_NOT_SENT)
mUser <- findUserByEmail' reqDto.email
case mUser of
Just user -> do
tenantUuid <- asks currentTenantUuid
actionKey <- createActionKey user.uuid ForgottenPasswordActionKey tenantUuid
catchError
(sendResetPasswordMail (toDTO user) actionKey.hash)
(\errMessage -> throwError $ GeneralServerError _ERROR_SERVICE_USER__RECOVERY_EMAIL_NOT_SENT)
Nothing -> return ()

changeUserState :: String -> Bool -> AppContextM ()
changeUserState hash active =
Expand Down

0 comments on commit a1f9f4a

Please sign in to comment.