Skip to content

Commit

Permalink
feat: fix authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Sep 10, 2024
1 parent 4f76bd6 commit e8d4f19
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private Mono<Void> validateUserFromGoogleToken(ServerWebExchange exchange, Gatew
return webClient.get()
.uri("https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" + token)
.retrieve()
.onStatus(status -> status.value() == 401, res -> Mono.error(new RuntimeException("AUTH")))
.bodyToMono(Map.class)
.flatMap(userInfo -> {
if (userInfo.containsKey("id")) {
Expand All @@ -56,7 +57,9 @@ private Mono<Void> validateUserFromGoogleToken(ServerWebExchange exchange, Gatew
}
}
return createSimpleErrorResponse(exchange, "AU0004", "인증에 실패했습니다");
});
})
.onErrorResume(error -> error.getMessage().equals("AUTH"),
error -> createSimpleErrorResponse(exchange, "AU0004", "인증에 실패했습니다"));
}

private Mono<Void> createSimpleErrorResponse(ServerWebExchange exchange, String code, String message) {
Expand Down

0 comments on commit e8d4f19

Please sign in to comment.