diff --git a/src/main/java/ice/spot/SpotApplication.java b/src/main/java/ice/spot/SpotApplication.java index 8ba15cb..cb29d3d 100644 --- a/src/main/java/ice/spot/SpotApplication.java +++ b/src/main/java/ice/spot/SpotApplication.java @@ -1,11 +1,19 @@ package ice.spot; +import jakarta.annotation.PostConstruct; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import java.util.TimeZone; + @SpringBootApplication public class SpotApplication { + @PostConstruct + public void init() { + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); + } + public static void main(String[] args) { SpringApplication.run(SpotApplication.class, args); } diff --git a/src/main/java/ice/spot/domain/User.java b/src/main/java/ice/spot/domain/User.java index 5c66be8..9e32a50 100644 --- a/src/main/java/ice/spot/domain/User.java +++ b/src/main/java/ice/spot/domain/User.java @@ -54,13 +54,13 @@ public class User { private String refreshToken; @Builder - public User(String serialId, String password, String nickname, ERole role, EProvider provider, Long point) { + public User(String serialId, String password, String nickname, ERole role, EProvider provider) { this.serialId = serialId; this.password = password; this.nickname = nickname; this.role = role; this.provider = provider; - this.point = point; + this.point = 0L; this.createdAt = LocalDate.now(); } @@ -68,6 +68,7 @@ public void register(String nickname) { this.nickname = nickname; this.createdAt = LocalDate.now(); this.role = ERole.USER; + this.point = 0L; } public void updateRefreshToken(String refreshToken) { diff --git a/src/main/java/ice/spot/security/info/KakaoOauth2UserInfo.java b/src/main/java/ice/spot/security/info/KakaoOauth2UserInfo.java index 456eaf2..cc1f656 100644 --- a/src/main/java/ice/spot/security/info/KakaoOauth2UserInfo.java +++ b/src/main/java/ice/spot/security/info/KakaoOauth2UserInfo.java @@ -13,4 +13,9 @@ public KakaoOauth2UserInfo(Map attributes) { public String getId() { return attributes.get("id").toString(); } + + @Override + public String getNickname() { + return attributes.get("nickname").toString(); + } } diff --git a/src/main/java/ice/spot/security/info/factory/Oauth2UserInfo.java b/src/main/java/ice/spot/security/info/factory/Oauth2UserInfo.java index 00c9389..187000d 100644 --- a/src/main/java/ice/spot/security/info/factory/Oauth2UserInfo.java +++ b/src/main/java/ice/spot/security/info/factory/Oauth2UserInfo.java @@ -10,4 +10,5 @@ public abstract class Oauth2UserInfo { protected final Map attributes; public abstract String getId(); + public abstract String getNickname(); } diff --git a/src/main/java/ice/spot/security/service/CustomOauth2UserDetailService.java b/src/main/java/ice/spot/security/service/CustomOauth2UserDetailService.java index 1a684da..9736397 100644 --- a/src/main/java/ice/spot/security/service/CustomOauth2UserDetailService.java +++ b/src/main/java/ice/spot/security/service/CustomOauth2UserDetailService.java @@ -52,8 +52,9 @@ public OAuth2User loadUser( bCryptPasswordEncoder .encode(UUID.randomUUID().toString()) ) + .nickname(oauth2UserInfo.getNickname()) .provider(provider) - .role(ERole.GUEST) + .role(ERole.USER) .build() ); return UserRepository.UserSecurityForm.invoke(newUser);