a little cleaning
This commit is contained in:
parent
e069bde130
commit
9e925816e4
2 changed files with 13 additions and 6 deletions
12
src/Main.hs
12
src/Main.hs
|
@ -126,9 +126,9 @@ users =
|
||||||
-- void $ liftIO $ runUpdate_ conn (updateUser id us (utctDay now))
|
-- void $ liftIO $ runUpdate_ conn (updateUser id us (utctDay now))
|
||||||
userDetailsSelect conn id
|
userDetailsSelect conn id
|
||||||
else
|
else
|
||||||
throwError $ err403
|
throwError $ err403
|
||||||
{ errBody = "Wrong Authorization present"
|
{ errBody = "Wrong Authorization present"
|
||||||
}
|
}
|
||||||
|
|
||||||
userPostUpdate :: Maybe Int -> Int -> UserDetailsSubmit -> MateHandler ()
|
userPostUpdate :: Maybe Int -> Int -> UserDetailsSubmit -> MateHandler ()
|
||||||
userPostUpdate Nothing _ _ =
|
userPostUpdate Nothing _ _ =
|
||||||
|
@ -142,9 +142,9 @@ users =
|
||||||
conn <- rsConnection <$> ask
|
conn <- rsConnection <$> ask
|
||||||
void $ liftIO $ runUpdate_ conn (updateUserDetails id uds (utctDay now))
|
void $ liftIO $ runUpdate_ conn (updateUserDetails id uds (utctDay now))
|
||||||
else
|
else
|
||||||
throwError $ err403
|
throwError $ err403
|
||||||
{ errBody = "Wrong Authorization present"
|
{ errBody = "Wrong Authorization present"
|
||||||
}
|
}
|
||||||
|
|
||||||
beverages =
|
beverages =
|
||||||
list :<|>
|
list :<|>
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue