From 6d5f833876260e2c7726227426fa1e860daaee18 Mon Sep 17 00:00:00 2001 From: uwoobeat Date: Wed, 31 Jan 2024 13:42:17 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8B=9C=ED=81=90=EB=A6=AC=ED=8B=B0=20?= =?UTF-8?q?=EC=9C=A0=ED=8B=B8=EC=9D=B4=20=EB=A9=A4=EB=B2=84=20ID=20?= =?UTF-8?q?=ED=8C=8C=EC=8B=B1=EC=97=90=20=EC=8B=A4=ED=8C=A8=ED=95=A0=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=BB=A4=EC=8A=A4=ED=85=80=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EB=8D=98=EC=A7=80=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/depromeet/global/util/SecurityUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/depromeet/global/util/SecurityUtil.java b/src/main/java/com/depromeet/global/util/SecurityUtil.java index c109d0c52..aa4af8f13 100644 --- a/src/main/java/com/depromeet/global/util/SecurityUtil.java +++ b/src/main/java/com/depromeet/global/util/SecurityUtil.java @@ -1,5 +1,7 @@ package com.depromeet.global.util; +import com.depromeet.global.error.exception.CustomException; +import com.depromeet.global.error.exception.ErrorCode; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; @@ -9,6 +11,10 @@ public class SecurityUtil { public Long getCurrentMemberId() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - return Long.parseLong(authentication.getName()); + try { + return Long.parseLong(authentication.getName()); + } catch (Exception e) { + throw new CustomException(ErrorCode.AUTH_NOT_FOUND); + } } }