/gist:608d1e8304d96a3787bc Secret
Last active
August 29, 2015 14:19
-
-
Save vendethiel/608d1e8304d96a3787bc 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 safeHead (fromRows `fmap` query conn sql (Only emailAddress)) >>= makeUser | |
where makeUser :: (String, String, ByteString) -> Maybe User | |
makeUser (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