-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from swm-nodriversomabus/FIX-DEV-SECURITY-114
feat(BE): 로그인한 사용자 자동 인식 #115
- Loading branch information
Showing
4 changed files
with
5 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ public CustomException(ErrorCodeEnum e) { | |
this.errorCodeEnum = e; | ||
this.message = e.getMessage(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
src/main/java/com/example/api/common/utils/AuthenticationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
package com.example.api.common.utils; | ||
|
||
import com.example.api.auth.domain.SecurityUser; | ||
import com.example.api.user.domain.User; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
|
||
/** | ||
* 이걸로 유저 정보를 가져오자 | ||
*/ | ||
public class AuthenticationUtils { | ||
public static SecurityUser getCurrentUserAuthentication(){ | ||
public static SecurityUser getCurrentUserAuthentication() { | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
if (authentication != null && authentication.getPrincipal() instanceof SecurityUser){ | ||
if (authentication != null && authentication.getPrincipal() instanceof SecurityUser) { | ||
return (SecurityUser) authentication.getPrincipal(); | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters