Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CriMDev97 committed Nov 16, 2023
1 parent 8881d43 commit ea340bb
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public Mono<DecodedJWT> apply(ServerWebExchange serverWebExchange) {
return Mono.justOrEmpty(serverWebExchange)
.map(JWTUtil::getAuthorizationPayload)
.filter(Objects::nonNull)
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_PRESENT, JWT_NOT_PRESENT.getMessage(), HttpStatus.UNAUTHORIZED)))
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_PRESENT, JWT_NOT_PRESENT.getMessage(), HttpStatus.FORBIDDEN)))
.filter(JWTUtil.matchBearerLength())
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_PRESENT, JWT_NOT_PRESENT.getMessage(), HttpStatus.UNAUTHORIZED)))
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_PRESENT, JWT_NOT_PRESENT.getMessage(), HttpStatus.FORBIDDEN)))
.map(JWTUtil.getBearerValue())
.filter(token -> !token.isEmpty())
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_PRESENT, JWT_NOT_PRESENT.getMessage(), HttpStatus.UNAUTHORIZED)))
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_PRESENT, JWT_NOT_PRESENT.getMessage(), HttpStatus.FORBIDDEN)))
.map(JWTUtil.decodeJwt())
.filter(fieldsCheck())
.map(validateToken())
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_VALID, JWT_NOT_VALID.getMessage(), HttpStatus.UNAUTHORIZED)));
.switchIfEmpty(Mono.error(new PDNDGenericException(JWT_NOT_VALID, JWT_NOT_VALID.getMessage(), HttpStatus.FORBIDDEN)));
}

private Predicate<DecodedJWT> fieldsCheck(){
Expand Down

0 comments on commit ea340bb

Please sign in to comment.