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/#168 로그인api 반환 값 변경 #169

Merged
merged 6 commits into from
Aug 26, 2024

Conversation

llddang
Copy link
Contributor

@llddang llddang commented Aug 26, 2024

관련 이슈

작업 요약

[BACKEND]

  • 로그인 후 반환에서 id 속성의 값을 member_id 가 아니라 student_id 혹은 faculty_id로 수정했습니다.

리뷰 요구 사항

  • 리뷰 예상 시간: 3분

@llddang llddang added ✨ 기능 개발 새로운 기능을 구현하는 데 필요한 작업 또는 변경 사항 🌑 백엔드 백엔드 개발 labels Aug 26, 2024
@llddang llddang requested review from amaran-th and tkschkim August 26, 2024 05:14
@llddang llddang self-assigned this Aug 26, 2024
Comment on lines +45 to +58
if (memberDetail instanceof StudentMember studentMember) {
String role = Role.ROLE_MEMBER.toString();

String accessToken = jwtTokenProvider.createToken(member.getId(), role);
String accessToken = jwtTokenProvider.createToken(member.getId(), role);

return SignInResponse.of(member, role, isModerator, accessToken);
return SignInResponse.of(member, studentMember.getId(), role, false, accessToken);

} else if (memberDetail instanceof FacultyMember facultyMember) {
String role = Role.ROLE_ADMIN.toString();

String accessToken = jwtTokenProvider.createToken(member.getId(), role);

return SignInResponse.of(member, facultyMember.getId(), role, true, accessToken);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분에서 if문을 사용하지 않고 할 수 있는 방법이 있을까요?
코드가 약간 더러운 느낌이라서요...
아는 방법있으면 알려주세용!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고민을 해봤는데 지금 구조상 지금 방법이 최선인 것 같습니다!

Copy link
Contributor

@amaran-th amaran-th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

금방 수정할 수 있는 부분이라 approve했습니다!
확인 부탁드려요~

Comment on lines +45 to +58
if (memberDetail instanceof StudentMember studentMember) {
String role = Role.ROLE_MEMBER.toString();

String accessToken = jwtTokenProvider.createToken(member.getId(), role);
String accessToken = jwtTokenProvider.createToken(member.getId(), role);

return SignInResponse.of(member, role, isModerator, accessToken);
return SignInResponse.of(member, studentMember.getId(), role, false, accessToken);

} else if (memberDetail instanceof FacultyMember facultyMember) {
String role = Role.ROLE_ADMIN.toString();

String accessToken = jwtTokenProvider.createToken(member.getId(), role);

return SignInResponse.of(member, facultyMember.getId(), role, true, accessToken);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고민을 해봤는데 지금 구조상 지금 방법이 최선인 것 같습니다!

@@ -11,7 +11,7 @@ public record SignInResponse(
String token
) {

public static SignInResponse of(Member member, String role, Boolean isModerator, String token) {
return new SignInResponse(member.getId(), member.getName(), member.getEmail(), role, isModerator, token);
public static SignInResponse of(Member member, long member_id, String role, Boolean isModerator, String token) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소한거긴 한데 객체로 다룰 수 있는 Long 타입을 사용해주시면 좋을 것 같습니다!
그리고 변수명은 카멜케이스로 부탁드립니다! (memberId)

email varchar(255) not null,
name varchar(255) not null,
password varchar(255) not null,
phone_number varchar(255) not null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_authorized 값은 필요하지 않은 값인가요??👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넹.
이전에는 메일인증을 회원가입 다하고 난 뒤에 진행하는 방식이라서 메일 인증이 완료되었는지 필요했습니다.
하지만 지금은 회원가입 단계에서 메일인증을 받으므로 필요가 없어졌습니다.

혹시 다른 일 관련으로 사용처가 있었을까요?

@llddang llddang merged commit 640affd into main Aug 26, 2024
2 checks passed
@llddang llddang deleted the Feature/#168-로그인API_반환_값_변경 branch August 26, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ 기능 개발 새로운 기능을 구현하는 데 필요한 작업 또는 변경 사항 🌑 백엔드 백엔드 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BACK] 로그인 API 반환 값 변경
2 participants