provide data of authenticated user
This commit is contained in:
parent
52f43c81eb
commit
f47e0b7cb0
@ -38,20 +38,20 @@ type Auth user userData = BasicAuth "login" user :> "auth" :> QueryParam "scopes
|
|||||||
type Token = "token" :> Post '[JSON] Text -- TODO post jwt token
|
type Token = "token" :> Post '[JSON] Text -- TODO post jwt token
|
||||||
-- type Insert = "insert" :> Post '[JSON] User
|
-- type Insert = "insert" :> Post '[JSON] User
|
||||||
|
|
||||||
authServer :: forall user userData . UserData user userData => [user] -> Server (Auth user userData)
|
authServer :: forall user userData . UserData user userData => Server (Auth user userData)
|
||||||
authServer testUsers = handleAuth
|
authServer = handleAuth
|
||||||
where
|
where
|
||||||
handleAuth :: user -> Maybe String -> Handler (Maybe userData)
|
handleAuth :: user -> Maybe String -> Handler (Maybe userData)
|
||||||
handleAuth _ Nothing = liftIO (putStrLn "no query param given") >> return Nothing
|
handleAuth _ Nothing = liftIO (putStrLn "no query param given") >> return Nothing
|
||||||
handleAuth _ (Just x) = do
|
handleAuth u (Just x) = do
|
||||||
let
|
let
|
||||||
scopes = readScopes @user @userData x
|
scopes = readScopes @user @userData x
|
||||||
ud = mconcat $ map (userScope @user @userData $ head testUsers) scopes
|
ud = mconcat $ map (userScope @user @userData u) scopes
|
||||||
liftIO (putStrLn $ "query param: " ++ showScopes @user @userData scopes)
|
liftIO (putStrLn $ "query param: " ++ showScopes @user @userData scopes)
|
||||||
return $ Just ud
|
return $ Just ud
|
||||||
|
|
||||||
exampleAuthServer :: Server (Auth User (Map.Map Text Text))
|
exampleAuthServer :: Server (Auth User (Map.Map Text Text))
|
||||||
exampleAuthServer = authServer testUsers
|
exampleAuthServer = authServer
|
||||||
|
|
||||||
authAPI :: Proxy (Auth User (Map.Map Text Text))
|
authAPI :: Proxy (Auth User (Map.Map Text Text))
|
||||||
authAPI = Proxy
|
authAPI = Proxy
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user