Skip to content

Commit

Permalink
feat: fix parseJwtToken bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Oct 20, 2023
1 parent 7f634d6 commit 15052b6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/casbin/casdoor/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ public User parseJwtToken(String token) {
// read "access_token" from payload and convert to CasdoorUser
try {
JWTClaimsSet claimsSet = parseJwt.getJWTClaimsSet();
String accessToken = claimsSet.getStringClaim("access_token");
String userJson = claimsSet == null ? null : claimsSet.toString();

if (accessToken == null || accessToken.isEmpty()) {
throw new AuthException("Access token not found in JWT payload.");
if (userJson == null || userJson.isEmpty()) {
throw new AuthException("Cannot get claims from JWT payload");
}

return objectMapper.readValue(accessToken, User.class);
return objectMapper.readValue(userJson, User.class);
} catch (JsonProcessingException | java.text.ParseException e) {
throw new AuthException("Cannot read access token from JWT payload.", e);
throw new AuthException("Cannot convert claims to User", e);
}
}

Expand Down

0 comments on commit 15052b6

Please sign in to comment.