Skip to content

Commit

Permalink
[feature] 회원가입 시 응답 바디가 없도록 수정
Browse files Browse the repository at this point in the history
설명:
- 회원가입 시 로그인과 동일한 응답을 처리하는 점을 보고 고민 끝에 회원가입 시 바디는 없게 하고 로그인 시에 JWT 토큰을 받도록 수정하려 합니다.
  • Loading branch information
tkddn204 committed Jan 4, 2024
1 parent 04bfa3d commit d15199a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.coolpeace.domain.member.dto.request.RefreshAccessTokenRequest;
import com.coolpeace.domain.member.dto.response.MemberLoginResponse;
import com.coolpeace.domain.member.dto.response.MemberRefreshAccessTokenResponse;
import com.coolpeace.domain.member.dto.response.MemberRegisterResponse;
import com.coolpeace.domain.member.service.MemberService;
import com.coolpeace.global.jwt.security.JwtPrincipal;
import com.coolpeace.global.resolver.AuthJwtCredential;
Expand All @@ -32,11 +31,11 @@ public ResponseEntity<MemberLoginResponse> login(
}

@PostMapping("/register")
public ResponseEntity<MemberRegisterResponse> register(
public ResponseEntity<Void> register(
@Valid @RequestBody MemberRegisterRequest registerRequest
) {
return ResponseEntity.created(URI.create("/"))
.body(MemberRegisterResponse.from(memberService.registerAsOwner(registerRequest)));
memberService.registerAsOwner(registerRequest);
return ResponseEntity.created(URI.create("/")).build();
}

@GetMapping("/register/check/email")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,16 @@ public MemberLoginResponse login(MemberLoginRequest loginRequest) {
}

@Transactional
public JwtPair registerAsOwner(MemberRegisterRequest registerRequest) {
public void registerAsOwner(MemberRegisterRequest registerRequest) {
validateMemberEmail(registerRequest.email());
Role role = roleRepository.findByRoleType(RoleType.OWNER).orElseThrow(MemberRoleNotFoundException::new);
Member newMember = memberRepository.save(
memberRepository.save(
Member.from(
registerRequest.email(),
passwordEncoder.encode(registerRequest.password()),
registerRequest.name(),
role)
);

return jwtService.createTokenPair(
JwtPayload.fromNow(String.valueOf(newMember.getId()), newMember.getEmail()));
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit d15199a

Please sign in to comment.