Skip to content

Commit

Permalink
[Chore] 토큰 시간 조정, 로그인 시 가입 여부 응답 추가 (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youhoseong authored Jan 15, 2023
1 parent 5c4559a commit 4f20ce5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@Component
public class UserAssembler {

public UserSignUpResponse toUserSignUpResponse(User user, String accessToken) {
return UserSignUpResponse.of(user.getId(), accessToken);
public UserSignUpResponse toUserSignUpResponse(User user, boolean isAlreadySignedUp, String accessToken) {
return UserSignUpResponse.of(user.getId(), isAlreadySignedUp, accessToken);
}

public UserSignUpDto toUserSignUpDto(String vendorId, VendorType vendorType, String email) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class JwtUtils {
@Value("${jwt.secret}")
private String secretKey;

private final long tokenValidTime = 600 * 600 * 1000L;
// note. 약 41일
private final long tokenValidTime = 600 * 600 * 10000L;

private final UserDetailsService userDetailsService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package ccc.keeweapi.dto.user;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor(staticName = "of")
public class UserSignUpResponse {
private Long userId;
private boolean isAlreadySignedUp;
private String accessToken;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public <T extends OauthResponse> UserSignUpResponse signupWithOauth(String code,
Optional<User> userOps = userDomainService.getUserByVendorIdAndVendorType(account.getId(), vendorType);

if(userOps.isPresent()) {
return userAssembler.toUserSignUpResponse(userOps.get(), getToken(userOps.get().getId()));
return userAssembler.toUserSignUpResponse(userOps.get(), true, getToken(userOps.get().getId()));
}

User user = signUpWithOauth(
Expand All @@ -43,7 +43,7 @@ public <T extends OauthResponse> UserSignUpResponse signupWithOauth(String code,
, KeeweStringUtils.getOrDefault(account.getEmail(), "")
);

return userAssembler.toUserSignUpResponse(user, getToken(user.getId()));
return userAssembler.toUserSignUpResponse(user, false, getToken(user.getId()));
}

public String getToken(Long userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void kakao_signup() throws Exception {
// given
UserSignUpResponse userSignUpDto = UserSignUpResponse.of(
1L,
true,
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJoYXZlYWx3YXlzYmVlbkBrYWthby5jb20iLCJyb2xlcyI6W10sImlhdCI6MTY1NzQzNjU2MywiZXhwIjoxNjU3Nzk2NTYzfQ.AJX7rGRXjmi4TopUBsX6zWVgMYgjN_uRYtF_Yb_80KE"
);

Expand All @@ -58,6 +59,7 @@ void kakao_signup() throws Exception {
fieldWithPath("message").description("요청 결과 메세지"),
fieldWithPath("code").description("결과 코드"),
fieldWithPath("data.userId").description("생성된 유저 ID"),
fieldWithPath("data.alreadySignedUp").description("기존 회원가입 여부"),
fieldWithPath("data.accessToken").description("발급된 유저의 JWT"))
.tag("SignUp")
.build()
Expand All @@ -71,6 +73,7 @@ void naver_signup() throws Exception {
String state = "123456789";
UserSignUpResponse userSignUpDto = UserSignUpResponse.of(
1L,
true,
"[발급된 JWT]"
);

Expand All @@ -97,6 +100,7 @@ void naver_signup() throws Exception {
fieldWithPath("message").description("요청 결과 메세지"),
fieldWithPath("code").description("결과 코드"),
fieldWithPath("data.userId").description("생성된 유저 ID"),
fieldWithPath("data.alreadySignedUp").description("기존 회원가입 여부"),
fieldWithPath("data.accessToken").description("발급된 유저의 JWT"))
.tag("SignUp")
.build()
Expand All @@ -108,6 +112,7 @@ void naver_signup() throws Exception {
void google_signup() throws Exception {
UserSignUpResponse userSignUpDto = UserSignUpResponse.of(
1L,
true,
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJoYXZlYWx3YXlzYmVlbkBrYWthby5jb20iLCJyb2xlcyI6W10sImlhdCI6MTY1NzQzNjU2MywiZXhwIjoxNjU3Nzk2NTYzfQ.AJX7rGRXjmi4TopUBsX6zWVgMYgjN_uRYtF_Yb_80KE"
);

Expand All @@ -127,6 +132,7 @@ void google_signup() throws Exception {
fieldWithPath("message").description("요청 결과 메세지"),
fieldWithPath("code").description("결과 코드"),
fieldWithPath("data.userId").description("생성된 유저 ID"),
fieldWithPath("data.alreadySignedUp").description("기존 회원가입 여부"),
fieldWithPath("data.accessToken").description("발급된 유저의 JWT"))
.tag("SignUp")
.build()
Expand Down

0 comments on commit 4f20ce5

Please sign in to comment.