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

@ -126,9 +126,9 @@ users =
-- void $ liftIO $ runUpdate_ conn (updateUser id us (utctDay now))
userDetailsSelect conn id
else
throwError $ err403
{ errBody = "Wrong Authorization present"
}
throwError $ err403
{ errBody = "Wrong Authorization present"
}
userPostUpdate :: Maybe Int -> Int -> UserDetailsSubmit -> MateHandler ()
userPostUpdate Nothing _ _ =
@ -142,9 +142,9 @@ users =
conn <- rsConnection <$> ask
void $ liftIO $ runUpdate_ conn (updateUserDetails id uds (utctDay now))
else
throwError $ err403
{ errBody = "Wrong Authorization present"
}
throwError $ err403
{ errBody = "Wrong Authorization present"
}
beverages =
list :<|>

View file

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