Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [Feature] - 서버 날짜 설정 및 유저 닉네임 설정 #15

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/ice/spot/SpotApplication.java
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ice/spot/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,21 @@ 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();
}

public void register(String nickname) {
this.nickname = nickname;
this.createdAt = LocalDate.now();
this.role = ERole.USER;
this.point = 0L;
}

public void updateRefreshToken(String refreshToken) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/ice/spot/security/info/KakaoOauth2UserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ public KakaoOauth2UserInfo(Map<String, Object> attributes) {
public String getId() {
return attributes.get("id").toString();
}

@Override
public String getNickname() {
return attributes.get("nickname").toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
public abstract class Oauth2UserInfo {
protected final Map<String, Object> attributes;
public abstract String getId();
public abstract String getNickname();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down