Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public Message unlinkAccount(Long userId) {
.message("회원 탈퇴에 성공 했습니다.")
.build();
}
@Transactional
public void changeIsRegistered(Long id) {
User user = userRepository.findById(id).get();
user.updateIsRegistered();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;

@Tag(name = "Authorization", description = "Authorization API")
@RestController
@RequestMapping("/auth")
Expand Down Expand Up @@ -59,7 +62,7 @@ public ResponseEntity<AuthRes> login(@RequestBody IdTokenReq idTokenReq) {
String email = authService.findEmail(providerId);

String accessToken = jwtUtil.createJwt("access", providerId, "ROLE_USER", 3600000L, email);

System.out.println("accessToken = " + accessToken);
User user = userRepository.findByProviderId(providerId)
.orElseThrow(EntityNotFoundException::new);

Expand All @@ -71,6 +74,17 @@ public ResponseEntity<AuthRes> login(@RequestBody IdTokenReq idTokenReq) {

return ResponseEntity.ok(authRes);
}
@Operation(summary = "회원 가입", description = "회원가입을 진행합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "로그인 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = AuthRes.class)))}),
@ApiResponse(responseCode = "400", description = "로그인 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
})
@PostMapping("/sign-up")
public ResponseEntity<?> signUp(@AuthenticationPrincipal UserPrincipal userPrincipal) {
authService.changeIsRegistered(userPrincipal.getId());

return ResponseEntity.ok().build();
}


@Operation(summary = "회원 탈퇴", description = "해당 유저의 가입을 탈퇴합니다.")
Expand All @@ -84,4 +98,5 @@ public ResponseEntity<Message> unlinkSocialAccount(
) {
return ResponseEntity.ok(authService.unlinkAccount(userPrincipal.getId()));
}

}
4 changes: 4 additions & 0 deletions src/main/java/com/movelog/domain/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ public User(String nickname, String username, String email, String role, String
this.providerId = providerId;
this.isRegistered = false;
}

public void updateIsRegistered() {
this.isRegistered = true;
}
}