renamed expected refresh token key

This commit is contained in:
David Mosbach 2024-01-30 20:35:12 +00:00
parent 3f2bf3cc6e
commit c8ed2166dc

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" }