feat: implement reservation MVP backend
This commit is contained in:
parent
85a6f1fbbc
commit
6fda098137
48 changed files with 1974 additions and 39 deletions
|
|
@ -0,0 +1,21 @@
|
|||
package com.reservation.demo.common.security;
|
||||
|
||||
import com.reservation.demo.common.exception.BusinessException;
|
||||
import com.reservation.demo.common.exception.ErrorCode;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
public final class SecurityUtils {
|
||||
|
||||
private SecurityUtils() {
|
||||
}
|
||||
|
||||
public static Long getCurrentUserId() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || authentication.getPrincipal() == null) {
|
||||
throw new BusinessException(ErrorCode.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
return (Long) authentication.getPrincipal();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue