diff --git a/src/Server.hs b/src/Server.hs index 976d463..dfdb44d 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -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" }