a little cleaning

This commit is contained in:
nek0 2019-07-18 16:10:18 +02:00
parent e069bde130
commit 9e925816e4
2 changed files with 13 additions and 6 deletions

View file

@ -47,6 +47,7 @@ import Types.Reader
import Model.User import Model.User
initToken :: PGS.Query initToken :: PGS.Query
initToken = "create table if not exists \"token\" (token_string bytea not null primary key, token_user integer references \"user\"(user_id) not null, token_expiry timestamptz not null)" initToken = "create table if not exists \"token\" (token_string bytea not null primary key, token_user integer references \"user\"(user_id) not null, token_expiry timestamptz not null)"
@ -67,6 +68,7 @@ tokenTable = table "token" (
) )
) )
getUserAuthInfo getUserAuthInfo
:: Int :: Int
-> MateHandler AuthInfo -> MateHandler AuthInfo
@ -99,6 +101,7 @@ getUserAuthInfo ident = do
) )
users users
validateToken validateToken
:: PGS.Connection :: PGS.Connection
-> ByteString -> ByteString
@ -131,6 +134,7 @@ validateToken conn header = do
{ errBody = "No valid token found!" { errBody = "No valid token found!"
} }
generateToken generateToken
:: Ticket :: Ticket
-> AuthHash -> AuthHash
@ -164,6 +168,7 @@ generateToken (Ticket _ ident exp) (AuthHash hash) = do
else else
return Denied return Denied
insertToken insertToken
:: Token :: Token
-> Insert [ByteString] -> Insert [ByteString]
@ -180,6 +185,7 @@ insertToken (Token tString tUser tExpiry) = Insert
, iOnConflict = Nothing , iOnConflict = Nothing
} }
deleteToken deleteToken
:: ByteString :: ByteString
-> Opaleye.Delete Int64 -> Opaleye.Delete Int64
@ -213,6 +219,7 @@ newTicket ident = do
liftIO $ atomically $ modifyTVar store (\s -> S.insert ticket s) liftIO $ atomically $ modifyTVar store (\s -> S.insert ticket s)
return (AuthTicket rand) return (AuthTicket rand)
processAuthRequest processAuthRequest
:: AuthRequest :: AuthRequest
-> MateHandler AuthResult -> MateHandler AuthResult