WIP: converting app request handlers

This commit is contained in:
Joe Nelson
2014-12-06 17:42:17 -08:00
parent 9b7af0296e
commit cb80dba234
6 changed files with 322 additions and 260 deletions
+10
View File
@@ -1,6 +1,9 @@
module Auth where
import qualified Data.Aeson as JSON
import qualified Data.ByteString.Char8 as BS
import Control.Monad (mzero)
import Control.Applicative ( (<*>), (<$>) )
import Crypto.BCrypt
import Database.PostgreSQL.Simple
import GHC.Int
@@ -11,6 +14,13 @@ data AuthUser = AuthUser {
, userRole :: String
}
instance JSON.FromJSON AuthUser where
parseJSON (JSON.Object v) = AuthUser <$>
v JSON..: "id" <*>
v JSON..: "pass" <*>
v JSON..: "role"
parseJSON _ = mzero
type DbRole = BS.ByteString
data LoginAttempt =