-
-
Save rightfold/a921911af024e2a01ae7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findUserByEmailAddress :: Connection -> EmailAddress -> IO (Maybe User) | |
findUserByEmailAddress conn (EmailAddress emailAddress) = | |
let sql = "select id, email_address, password_hash from users where email_address = $1" | |
in fromRows `fmap` query conn sql (Only emailAddress) | |
where fromRows :: [(String, String, ByteString)] -> Maybe User | |
fromRows [] = Nothing | |
fromRows [(id, emailAddress, passwordHash)] = | |
Just $ User (UserID . fromJust . UUID.fromString $ id) | |
(EmailAddress emailAddress) | |
(PasswordHash passwordHash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment