Skip to content

Commit

Permalink
feat: 인가 코드 받아오는 메서드 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
hoyeonyy committed Aug 15, 2024
1 parent f76878f commit cae2b79
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
package mouda.backend.auth.controller;

import lombok.RequiredArgsConstructor;
import mouda.backend.auth.dto.request.LoginRequest;
import mouda.backend.auth.dto.response.LoginResponse;
import mouda.backend.auth.service.AuthService;
import mouda.backend.common.RestResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;
import mouda.backend.auth.dto.request.LoginRequest;
import mouda.backend.auth.dto.response.LoginResponse;
import mouda.backend.auth.service.AuthService;
import mouda.backend.common.RestResponse;
import mouda.backend.member.domain.Member;
import mouda.backend.member.repository.MemberRepository;

@RestController
@RequestMapping("/v1/auth")
@RequiredArgsConstructor
public class AuthController implements AuthSwagger {

private final AuthService authService;
private final AuthService authService;
private final MemberRepository memberRepository;

@Override
@PostMapping("/login")
public ResponseEntity<RestResponse<LoginResponse>> login(@RequestBody LoginRequest loginRequest) {
LoginResponse response = authService.login(loginRequest);

@Override
@PostMapping("/login")
public ResponseEntity<RestResponse<LoginResponse>> login(@RequestBody LoginRequest loginRequest) {
LoginResponse response = authService.login(loginRequest);
return ResponseEntity.ok().body(new RestResponse<>(response));
}

return ResponseEntity.ok().body(new RestResponse<>(response));
}
@GetMapping("/kakao/oauth")
public void kakao(
@RequestParam("code") String code,
@RequestParam("error") String error,
@RequestParam("error_description") String error_description,
@RequestParam("state") String state
) {
System.out.println(code);
Member member = new Member(code);
memberRepository.save(member);
}
}
6 changes: 3 additions & 3 deletions backend/src/main/java/mouda/backend/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ private void validateNickname(String nickname) {
if (nickname.isBlank()) {
throw new MoimException(HttpStatus.BAD_REQUEST, MoimErrorMessage.MEMBER_NICKNAME_NOT_EXISTS);
}
if (nickname.length() >= NICKNAME_MAX_LENGTH) {
throw new MoimException(HttpStatus.BAD_REQUEST, MoimErrorMessage.MEMBER_NICKNAME_TOO_LONG);
}
// if (nickname.length() >= NICKNAME_MAX_LENGTH) {
// throw new MoimException(HttpStatus.BAD_REQUEST, MoimErrorMessage.MEMBER_NICKNAME_TOO_LONG);
// }
}

public void joinMoim(Moim moim) {
Expand Down

0 comments on commit cae2b79

Please sign in to comment.