From c131353de4f30d9f26b0febfb98ebe1acf3149ec Mon Sep 17 00:00:00 2001 From: willis plummer Date: Fri, 13 Sep 2019 13:26:38 -0400 Subject: [PATCH] downcase email addresses for account creation and authentication --- src/API.hs | 3 ++- src/Database.hs | 3 ++- stack.yaml.lock | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 stack.yaml.lock diff --git a/src/API.hs b/src/API.hs index c7e983e..22fc757 100644 --- a/src/API.hs +++ b/src/API.hs @@ -26,6 +26,7 @@ import qualified Data.ByteString.Char8 as B8 ( pack , unpack ) +import Data.Char (toLower) import Data.Int ( Int64 ) import Data.NewUser import Data.Proxy ( Proxy(..) ) @@ -243,7 +244,7 @@ loginHandler ) loginHandler cookieSettings jwtSettings connString (Login email password) = do - mUser <- liftIO $ fetchUserByEmailPG connString email + mUser <- liftIO $ fetchUserByEmailPG connString (toLower <$> email) case mUser of Nothing -> throwError err401 Just user -> do diff --git a/src/Database.hs b/src/Database.hs index 484abb9..84d8382 100644 --- a/src/Database.hs +++ b/src/Database.hs @@ -22,6 +22,7 @@ import Data.Int ( Int64 ) import qualified Data.ByteString as BS ( ByteString ) import qualified Data.ByteString.Char8 as B8 +import Data.Char (toLower) import Data.NewUser import Data.Pool ( Pool ) @@ -96,7 +97,7 @@ hashUser (NewUser name email pw) = do return $ (\hashedPW -> User { userName = name - , userEmail = email + , userEmail = toLower <$> email , userHashedPassword = hashedPW } ) diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..ecaf474 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 503674 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/10.yaml + sha256: 3f6a3139a4fe86c154496156ba9bc45328debae508485f0e314609eb9cc7e467 + original: lts-12.10