From 66161104bf09584dd0bef6539b93ba9f0d0a020e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C5=82eczek?= Date: Tue, 21 Oct 2025 12:06:03 +0200 Subject: [PATCH] refactor: Remove redundant VANull constructor in Auth.JWT module --- src/PostgREST/Auth/Jwt.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/PostgREST/Auth/Jwt.hs b/src/PostgREST/Auth/Jwt.hs index db88f1be9..734f302ab 100644 --- a/src/PostgREST/Auth/Jwt.hs +++ b/src/PostgREST/Auth/Jwt.hs @@ -55,10 +55,9 @@ decodeClaims _ = throwError $ JwtErr $ JwtDecodeErr UnsupportedTokenType validateClaims :: MonadError Error m => UTCTime -> (Text -> Bool) -> JSON.Object -> m () validateClaims time audMatches claims = liftEither $ maybeToLeft () (fmap JwtErr . getAlt $ JwtClaimsErr <$> checkForErrors time audMatches claims) -data ValidAud = VANull | VAString Text | VAArray [Text] deriving Generic +data ValidAud = VAString Text | VAArray [Text] deriving Generic instance JSON.FromJSON ValidAud where - parseJSON JSON.Null = pure VANull - parseJSON o = JSON.genericParseJSON JSON.defaultOptions { JSON.sumEncoding = JSON.UntaggedValue } o + parseJSON = JSON.genericParseJSON JSON.defaultOptions { JSON.sumEncoding = JSON.UntaggedValue } checkForErrors :: (Applicative m, Monoid (m JwtClaimsError)) => UTCTime -> (Text -> Bool) -> JSON.Object -> m JwtClaimsError checkForErrors time audMatches = mconcat @@ -82,7 +81,6 @@ checkForErrors time audMatches = mconcat validAud = \case (VAString aud) -> audMatches aud (VAArray auds) -> null auds || any audMatches auds - _ -> True checkValue invalid msg val = if invalid val then