User Queries #4

Merged
mosbach merged 6 commits from user-queries into main 2024-02-18 20:39:00 +01:00
Showing only changes of commit c8ed2166dc - Show all commits

View File

@ -201,7 +201,7 @@ instance FromHttpApiData AuthFlow where
instance FromForm ClientData where
fromForm f = ClientData
<$> (((parseUnique @AuthFlow "grant_type" f) *> (Left . ACode <$> parseUnique "code" f))
<|> ((parseUnique @String "refresh_token" f) *> (Right <$> parseUnique "refresh_token" f)))
<|> ((parseUnique @String "grant_type" f >>= \p -> if p == "refresh_token" then Right p else Left (pack p)) *> (Right <$> parseUnique "refresh_token" f)))
<*> parseMaybe "client_id" f
<*> parseMaybe "client_secret" f
<*> parseMaybe "redirect_uri" f
@ -220,6 +220,7 @@ tokenEndpoint = provideToken
where
provideToken :: ClientData -> AuthHandler user JWTWrapper
provideToken client = do
liftIO . putStrLn $ "Mock Server: received client data @ /token: " ++ show client
unless (isNothing (clientID client >> clientSecret client)
|| Client (pack . fromJust $ clientID client) (pack . fromJust $ clientSecret client) `elem` trustedClients) .
throwError $ err500 { errBody = "Invalid client" }