Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit 1cf5a00

Browse files
Added MalformedJwtException catch
Signed-off-by: JannikEmmerich <[email protected]>
1 parent c122d6f commit 1cf5a00

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/main/java/net/cryptic_game/backend/server/server/http/HttpUserEndpoints.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.JsonObject;
44
import com.google.gson.JsonParseException;
55
import io.jsonwebtoken.ExpiredJwtException;
6+
import io.jsonwebtoken.MalformedJwtException;
67
import io.jsonwebtoken.security.SignatureException;
78
import io.netty.handler.codec.http.HttpResponseStatus;
89
import lombok.RequiredArgsConstructor;
@@ -39,7 +40,7 @@ public ApiResponse login(@ApiParameter(id = "access_token") final String accessT
3940
final JsonObject accessToken;
4041
try {
4142
accessToken = SecurityUtils.parseJwt(key, accessTokenJwt);
42-
} catch (JsonParseException | SignatureException e) {
43+
} catch (JsonParseException | SignatureException | MalformedJwtException e) {
4344
return new ApiResponse(HttpResponseStatus.UNAUTHORIZED, "INVALID_TOKEN");
4445
} catch (ExpiredJwtException e) {
4546
return new ApiResponse(HttpResponseStatus.UNAUTHORIZED, "TOKEN_EXPIRED");
@@ -79,7 +80,7 @@ public ApiResponse register(@ApiParameter(id = "access_token") final String acce
7980
final JsonObject accessToken;
8081
try {
8182
accessToken = SecurityUtils.parseJwt(key, accessTokenJwt);
82-
} catch (JsonParseException | SignatureException e) {
83+
} catch (JsonParseException | SignatureException | MalformedJwtException e) {
8384
return new ApiResponse(HttpResponseStatus.UNAUTHORIZED, "INVALID_TOKEN");
8485
} catch (ExpiredJwtException e) {
8586
return new ApiResponse(HttpResponseStatus.UNAUTHORIZED, "TOKEN_EXPIRED");

0 commit comments

Comments
 (0)