Skip to content

Commit

Permalink
fix: 시큐리티 유틸이 멤버 ID 파싱에 실패할 경우 커스텀 예외 던지도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
uwoobeat committed Jan 31, 2024
1 parent 37b8170 commit 6d5f833
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/depromeet/global/util/SecurityUtil.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}
}

0 comments on commit 6d5f833

Please sign in to comment.