mateamt/src/Control/Auth.hs
2019-09-15 11:01:47 +02:00

31 lines
627 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Control.Auth where
import Servant
-- internal imports
import Types
import Model
authGet :: TicketRequest -> MateHandler AuthInfo
authGet (TicketRequest uid method) = do
getUserAuthInfo uid method
authSend :: AuthRequest -> MateHandler AuthResult
authSend = processAuthRequest
authLogout :: Maybe Int -> Int -> MateHandler ()
authLogout (Just muid) luid = do
if muid == luid
then
processLogout luid
else
throwError $ err401
{ errBody = "Unauthorized access"
}
authLogout Nothing _ = do
throwError $ err401
{ errBody = "Unauthorized access"
}