Skip to content

Commit

Permalink
Merge pull request #52 from TEAM-DHS/feat/member
Browse files Browse the repository at this point in the history
[FIX] 인증 정보 찾지 못했을 경우 예외를 던지지 않고 null 리턴
  • Loading branch information
xyzwv authored Nov 25, 2023
2 parents 238923d + 1cda62a commit d4e34e0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/efub/dhs/global/utils/SecurityUtils.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.efub.dhs.global.utils;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.server.ResponseStatusException;

public class SecurityUtils {

public static String getCurrentUsername() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || authentication.getName() == null) {
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "There is no authentication information.");
return null;
}
return authentication.getName();
}
Expand Down

0 comments on commit d4e34e0

Please sign in to comment.