Skip to content

Commit

Permalink
Merge pull request #10 from Central-MakeUs/fix/login
Browse files Browse the repository at this point in the history
[Fix} User entity 필드 변경
  • Loading branch information
AlmondBreez3 authored Jan 9, 2024
2 parents 1c3de8b + 868509a commit 19d7936
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ jobs:
sudo touch .env
echo "${{ secrets.ENV }}" | sudo tee .env > /dev/null
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_REPO }}:latest
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_REPO }}:latest
docker-compose -f ~/Youngduck-Server/docker-compose.dev.yml --env-file ~/Youngduck-Server/.env up --build -d
docker image prune -a -f
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public OauthSignInResponse oauthUserCodeLogin(
return oauthLoginUseCase.loginWithCode(provider, code, referer);
}

@Operation(summary = "개발용 로그인", deprecated = true)
@GetMapping("/login/{provider}/dev")
public OauthSignInResponse oauthUserLoginDev(
@PathVariable("provider") OauthProvider provider, @RequestParam("code") String code) {
return oauthLoginUseCase.devLogin(provider, code);
}



@Operation(summary = "로그인 (idtoken 용)", description = "회원가입 안된 유저일 경우, canLogin=false 값을 보냅니다!")
@PostMapping("/login/{provider}/idtoken")
public OauthSignInResponse oauthUserIdTokenLogin(
Expand All @@ -65,5 +74,13 @@ public OauthRegisterResponse oauthUserRegister(
return oauthRegisterUseCase.execute(provider, idToken, registerRequest);
}

@Operation(summary = "회원가입 (개발용)", deprecated = true)
@PostMapping("/register/{provider}/dev")
public OauthRegisterResponse oauthUserRegisterDev(
@PathVariable("provider") OauthProvider provider,
@RequestParam("idToken") String idToken, @RequestBody RegisterRequest registerRequest) {
return oauthRegisterUseCase.executeDev(provider, idToken, registerRequest);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ private OauthSignInResponse processLoginWithIdToken(OauthProvider provider, Stri
return checkUserCanLogin(oauthInfo, idToken);
}

@Transactional
public OauthSignInResponse devLogin(OauthProvider provider, String code) {
final OauthTokenResponse oauthTokenResponse = oauthHelper.getCredentialDev(provider, code);
return processLoginWithIdTokenDev(provider, oauthTokenResponse.getIdToken());
}

private OauthSignInResponse processLoginWithIdTokenDev(OauthProvider provider, String idToken) {
final OauthInfo oauthInfo = oauthHelper.getOauthInfoDev(provider, idToken);
return checkUserCanLogin(oauthInfo, idToken);
}


private OauthSignInResponse checkUserCanLogin(OauthInfo oauthInfo, String idToken) {
if (userDomainService.checkUserCanLogin(oauthInfo)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public OauthRegisterResponse execute(
return OauthRegisterResponse.from(tokenGenerateHelper.execute(user));
}

@Transactional
public OauthRegisterResponse executeDev(
OauthProvider provider,
String idToken,
RegisterRequest request) {
final OauthInfo oauthInfo = oauthHelper.getOauthInfoDev(provider, idToken);
final User user = registerUser(provider, oauthInfo, request);
return OauthRegisterResponse.from(tokenGenerateHelper.execute(user));
}


private User registerUser(
OauthProvider provider,
OauthInfo oauthInfo,
Expand Down
19 changes: 14 additions & 5 deletions Domain/src/main/java/com/example/domains/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class User extends BaseTimeEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String name;

@NotNull
private String nickname;
@Embedded
Expand All @@ -42,24 +44,22 @@ public class User extends BaseTimeEntity {
private List<Genre> genres = new ArrayList<>();

@Enumerated(EnumType.STRING)
private Level level = Level.LEVEL_ONE;
private Level level = Level.ONE;

private String phoneNumber;
// private String phoneNumber;

@Builder
private User (
String nickname,
List<Genre> genres,
boolean lawAgreement,
boolean isVerified,
OauthInfo oauthInfo,
Level level
OauthInfo oauthInfo
){
this.nickname = nickname;
this.lawAgreement = lawAgreement;
this.isVerified = isVerified;
this.oauthInfo = oauthInfo;
this.level = level;
this.genres = genres;
}

Expand All @@ -68,6 +68,7 @@ public static User of(
List<Genre> genres,
boolean lawAgreement,
OauthInfo oauthInfo

){
return User.builder()
.nickname(nickname)
Expand All @@ -89,5 +90,13 @@ public void validateUserStateNormal() {
}
}

public void updateInfo(String name, List<Genre> genres) {
if (!UserState.ACTIVE.equals(this.userState)) {
throw ServerForbiddenException.EXCEPTION;
}
this.nickname = nickname;
this.genres = genres;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
@AllArgsConstructor
@Getter
public enum Level {
LEVEL_ONE("1"),
ONE("LEVEL_ONE"),
// 탈퇴한유저
LEVEL_TWO("2");
TWO("LEVEL_TWO");

private String value;
}
2 changes: 1 addition & 1 deletion Domain/src/main/resources/application-domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spring:

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/youngducklocal
url: jdbc:mysql://localhost:3306/youngduck
username: root
password: root

Expand Down

0 comments on commit 19d7936

Please sign in to comment.