-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 9주차 미션_링크 #41
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
base: link
Are you sure you want to change the base?
[FEAT] 9주차 미션_링크 #41
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.example.umc10th.domain.member.controller; | ||
|
|
||
| import com.example.umc10th.domain.member.dto.UserLoginRequestDTO; | ||
| import com.example.umc10th.domain.member.dto.UserLoginResponseDTO; | ||
| import com.example.umc10th.domain.member.exception.code.MemberSuccessCode; | ||
| import com.example.umc10th.domain.member.service.MemberService; | ||
| import com.example.umc10th.global.apiPayload.ApiResponse; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| // 인증 관련 REST API를 처리하는 컨트롤러입니다. | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/auth") | ||
| public class AuthController { | ||
|
|
||
| private final MemberService memberService; | ||
|
|
||
| // 로그인 요청을 처리하고 JWT 토큰을 발급합니다. | ||
| @PostMapping("/login") | ||
| public ResponseEntity<ApiResponse<UserLoginResponseDTO>> login( | ||
| @RequestBody @Valid UserLoginRequestDTO request | ||
| ) { | ||
| UserLoginResponseDTO response = memberService.login(request); | ||
|
|
||
| return ResponseEntity.ok(ApiResponse.onSuccess(MemberSuccessCode.LOGIN_SUCCESS, response)); | ||
| } | ||
| } |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Email 어노테이션으로 검증해주는거 좋네! 하지만 @Email 어노테이션은 허점이 많아서 검증이 제대로 안될 수 있다고 하네! 첨부한 링크 가볍게 읽어보는거 추천해~(링크가 아래 링크 읽는거 추천) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.example.umc10th.domain.member.dto; | ||
|
|
||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import lombok.Getter; | ||
|
|
||
| // 로그인 요청 정보를 담는 DTO입니다. | ||
| @Getter | ||
| public class UserLoginRequestDTO { | ||
|
|
||
| // 로그인에 사용할 이메일입니다. | ||
| @NotBlank(message = "이메일은 필수입니다.") | ||
| @Email(message = "이메일 형식이 올바르지 않습니다.") | ||
| private String email; | ||
|
|
||
| // 로그인에 사용할 비밀번호입니다. | ||
| @NotBlank(message = "비밀번호는 필수입니다.") | ||
| private String password; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.example.umc10th.domain.member.dto; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| // 로그인 응답 정보를 담는 DTO입니다. | ||
| @Getter | ||
| @Builder | ||
| public class UserLoginResponseDTO { | ||
|
|
||
| // JWT Access Token입니다. | ||
| private String accessToken; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로그인 응답으로 요렇게 액세스토큰 자체만 내려주는구나! 나는 만료시간까지 같이 내려주는걸 추천하긴 해! 만료시간이 왜 필요한지도 링크가 한번 찾아보면 좋겠다..! |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| public enum MemberErrorCode implements BaseErrorCode { | ||
|
|
||
| MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER404", "사용자를 찾을 수 없습니다."), | ||
| MEMBER_PASSWORD_NOT_MATCH(HttpStatus.UNAUTHORIZED, "MEMBER401", "비밀번호가 일치하지 않습니다."), | ||
| MEMBER_EMAIL_ALREADY_EXISTS(HttpStatus.CONFLICT, "MEMBER409", "이미 가입된 이메일입니다."); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 분기하면 로그인 API에서 이메일 가입 여부를 추측할 수 있게되니까, 로그인 실패는 하나로 합치는게 더 좋아보인다!! |
||
|
|
||
| // HTTP 응답 상태입니다. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home 이랑 /mypage API가 둘 다 컨트롤러에서 memberService의 getmyPage()를 호출하고 있어! 응답도 마찬가지로 둘 다 HomeResponseDTO에 담고 있는데 둘이 섞였나?? 확인 한번 해봐야할 것 같아!