Skip to content

Commit 6616110

Browse files
mkleczeklaurenceisla
authored andcommitted
refactor: Remove redundant VANull constructor in Auth.JWT module
1 parent 5a4e2e4 commit 6616110

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/PostgREST/Auth/Jwt.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ decodeClaims _ = throwError $ JwtErr $ JwtDecodeErr UnsupportedTokenType
5555
validateClaims :: MonadError Error m => UTCTime -> (Text -> Bool) -> JSON.Object -> m ()
5656
validateClaims time audMatches claims = liftEither $ maybeToLeft () (fmap JwtErr . getAlt $ JwtClaimsErr <$> checkForErrors time audMatches claims)
5757

58-
data ValidAud = VANull | VAString Text | VAArray [Text] deriving Generic
58+
data ValidAud = VAString Text | VAArray [Text] deriving Generic
5959
instance JSON.FromJSON ValidAud where
60-
parseJSON JSON.Null = pure VANull
61-
parseJSON o = JSON.genericParseJSON JSON.defaultOptions { JSON.sumEncoding = JSON.UntaggedValue } o
60+
parseJSON = JSON.genericParseJSON JSON.defaultOptions { JSON.sumEncoding = JSON.UntaggedValue }
6261

6362
checkForErrors :: (Applicative m, Monoid (m JwtClaimsError)) => UTCTime -> (Text -> Bool) -> JSON.Object -> m JwtClaimsError
6463
checkForErrors time audMatches = mconcat
@@ -82,7 +81,6 @@ checkForErrors time audMatches = mconcat
8281
validAud = \case
8382
(VAString aud) -> audMatches aud
8483
(VAArray auds) -> null auds || any audMatches auds
85-
_ -> True
8684

8785
checkValue invalid msg val =
8886
if invalid val then

0 commit comments

Comments
 (0)