Skip to content

Commit

Permalink
Merge pull request #130 from swm-nodriversomabus/FIX-DEV-SECURITY-114
Browse files Browse the repository at this point in the history
feat(BE): 로그인한 사용자 자동 인식 #115
  • Loading branch information
Lemonade255 authored Oct 19, 2023
2 parents dd2c1dd + 1f41901 commit 82c7396
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public CustomException(ErrorCodeEnum e) {
this.errorCodeEnum = e;
this.message = e.getMessage();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public ResponseEntity<?> exceptionHandler(CustomException e) {
public ResponseEntity<?> methodArgumentNotValidException(MethodArgumentNotValidException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
}

@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<?> constraintViolationException(ConstraintViolationException e) {
log.error(e.getMessage());
Expand Down
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
@NoArgsConstructor
@AllArgsConstructor
public class SaveMatchingDto {

@NotNull
private UUID writerId;

@NotNull
private MatchingTypeEnum type;

Expand Down

0 comments on commit 82c7396

Please sign in to comment.