-
Notifications
You must be signed in to change notification settings - Fork 0
π Profile Modify #38
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
Conversation
|
Warning Rate limit exceeded@ohyuchan123 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 40 seconds before requesting another review. β How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. π¦ How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. π Files selected for processing (4)
μν¬μ€λ£¨μ΄ ν 리νμ€νΈλ μ¬μ©μ νλ‘ν λ° λΉλ°λ²νΈ μ
λ°μ΄νΈ κΈ°λ₯μ μΆκ°νλ λ³κ²½ μ¬νμ ν¬ν¨ν©λλ€. 보μ ꡬμ±μμ λ³κ²½ μ¬ν
μνμ€ λ€μ΄μ΄κ·Έλ¨sequenceDiagram
participant Client
participant ProfileController
participant MemberService
participant MemberRepository
participant Member
Client->>ProfileController: νλ‘ν μ
λ°μ΄νΈ μμ²
ProfileController->>MemberService: updateProfile(email, nickname, intro)
MemberService->>MemberRepository: findByEmail(email)
MemberRepository-->>MemberService: Member κ°μ²΄
MemberService->>Member: updateProfile(nickname, intro)
Member-->>MemberService: μ
λ°μ΄νΈλ Member
MemberService-->>ProfileController: μ
λ°μ΄νΈλ Member
ProfileController-->>Client: νλ‘ν μλ΅
κ΄λ ¨ κ°λ₯μ± μλ PR
ν λΌμ μ
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 8
π§Ή Nitpick comments (1)
src/main/java/com/mycom/socket/go_socket/entity/Member.java (1)
59-61: λΉλ°λ²νΈ μ λ°μ΄νΈ μ μ ν¨μ± κ²μ¦ μΆκ°λΉλ°λ²νΈ μ λ°μ΄νΈ μ μΈμ½λ©λ λΉλ°λ²νΈκ° nullμ΄ μλμ§ κ²μ¦μ΄ νμν©λλ€.
public void updatePassword(String encodedPassword) { + if (encodedPassword == null || encodedPassword.isBlank()) { + throw new IllegalArgumentException("λΉλ°λ²νΈλ nullμ΄κ±°λ λΉ κ°μΌ μ μμ΅λλ€."); + } this.password = encodedPassword; }
π Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
π Files selected for processing (6)
src/main/java/com/mycom/socket/auth/config/SecurityConfig.java(1 hunks)src/main/java/com/mycom/socket/go_socket/controller/ProfileController.java(1 hunks)src/main/java/com/mycom/socket/go_socket/dto/request/PasswordUpdateRequest.java(1 hunks)src/main/java/com/mycom/socket/go_socket/dto/request/ProfileUpdateRequest.java(1 hunks)src/main/java/com/mycom/socket/go_socket/entity/Member.java(1 hunks)src/main/java/com/mycom/socket/go_socket/service/MemberService.java(2 hunks)
| public record ProfileUpdateRequest( | ||
| String nickname, | ||
| String intro | ||
| ) {} No newline at end of file |
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.
π οΈ Refactor suggestion
νλ μ ν¨μ± κ²μ¦ μΆκ° νμ
νλ‘ν μ λ°μ΄νΈ μμ² DTOμ λ€μκ³Ό κ°μ μ ν¨μ± κ²μ¦ μ΄λ Έν μ΄μ μ μΆκ°νλ κ²μ΄ μ’μ΅λλ€:
public record ProfileUpdateRequest(
+ @NotBlank(message = "λλ€μμ νμμ
λλ€")
+ @Size(min = 2, max = 20, message = "λλ€μμ 2μ μ΄μ 20μ μ΄νμ¬μΌ ν©λλ€")
String nickname,
+ @Size(max = 100, message = "μκΈ°μκ°λ 100μλ₯Ό μ΄κ³Όν μ μμ΅λλ€")
String intro
) {}Committable suggestion skipped: line range outside the PR's diff.
| public record PasswordUpdateRequest( | ||
| String currentPassword, | ||
| String newPassword | ||
| ) {} |
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.
π οΈ Refactor suggestion
λΉλ°λ²νΈ μ ν¨μ± κ²μ¦ λ° λ³΄μ κ·μΉ μΆκ° νμ
λΉλ°λ²νΈ μ λ°μ΄νΈ μμ² DTOμ λ€μκ³Ό κ°μ 보μ κ²μ¦μ μΆκ°ν΄μΌ ν©λλ€:
public record PasswordUpdateRequest(
+ @NotBlank(message = "νμ¬ λΉλ°λ²νΈλ νμμ
λλ€")
String currentPassword,
+ @NotBlank(message = "μ λΉλ°λ²νΈλ νμμ
λλ€")
+ @Pattern(
+ regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,}$",
+ message = "λΉλ°λ²νΈλ 8μ μ΄μμ΄λ©°, μλ¬Έμ, μ«μ, νΉμλ¬Έμλ₯Ό ν¬ν¨ν΄μΌ ν©λλ€"
+ )
String newPassword
) {}π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public record PasswordUpdateRequest( | |
| String currentPassword, | |
| String newPassword | |
| ) {} | |
| public record PasswordUpdateRequest( | |
| @NotBlank(message = "νμ¬ λΉλ°λ²νΈλ νμμ λλ€") | |
| String currentPassword, | |
| @NotBlank(message = "μ λΉλ°λ²νΈλ νμμ λλ€") | |
| @Pattern( | |
| regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,}$", | |
| message = "λΉλ°λ²νΈλ 8μ μ΄μμ΄λ©°, μλ¬Έμ, μ«μ, νΉμλ¬Έμλ₯Ό ν¬ν¨ν΄μΌ ν©λλ€" | |
| ) | |
| String newPassword | |
| ) {} |
| if (!passwordEncoder.matches(currentPassword, member.getPassword())) { | ||
| throw new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€."); | ||
| } |
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.
보μ κ°μ : λΉλ°λ²νΈ μ€λ₯μ μ¬μ©μ μμμ λν μμΈ κ΅¬λΆ νμ
νμ¬ κ΅¬νμ μ¬μ©μλ₯Ό μ°Ύμ μ μλ κ²½μ°μ λΉλ°λ²νΈκ° μΌμΉνμ§ μλ κ²½μ°μ λμΌν μμΈλ₯Ό λ°μμν΅λλ€. μ΄λ 보μμ μ’μ§ μμ λ°©μμ λλ€.
- if (!passwordEncoder.matches(currentPassword, member.getPassword())) {
- throw new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€.");
- }
+ if (!passwordEncoder.matches(currentPassword, member.getPassword())) {
+ throw new InvalidPasswordException("νμ¬ λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.");
+ }Committable suggestion skipped: line range outside the PR's diff.
| @Transactional | ||
| public void updatePassword(String email, String currentPassword, String newPassword) { | ||
| Member member = memberRepository.findByEmail(email) | ||
| .orElseThrow(() -> new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€.")); | ||
|
|
||
| if (!passwordEncoder.matches(currentPassword, member.getPassword())) { | ||
| throw new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€."); | ||
| } | ||
|
|
||
| member.updatePassword(passwordEncoder.encode(newPassword)); | ||
| } |
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.
π οΈ Refactor suggestion
μ κ· λΉλ°λ²νΈ κ²μ¦ λ‘μ§ μΆκ° νμ
νμ¬ λΉλ°λ²νΈμ λμΌν μ λΉλ°λ²νΈλ₯Ό νμ©νλ λ¬Έμ κ° μμ΅λλ€. λν μ΄μ λΉλ°λ²νΈ μ¬μ¬μ©μ λν κ²μ¦μ΄ μμ΅λλ€.
@Transactional
public void updatePassword(String email, String currentPassword, String newPassword) {
Member member = memberRepository.findByEmail(email)
.orElseThrow(() -> new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€."));
if (!passwordEncoder.matches(currentPassword, member.getPassword())) {
- throw new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€.");
+ throw new InvalidPasswordException("νμ¬ λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.");
}
+ if (passwordEncoder.matches(newPassword, member.getPassword())) {
+ throw new InvalidPasswordException("μ λΉλ°λ²νΈλ νμ¬ λΉλ°λ²νΈμ λ¬λΌμΌ ν©λλ€.");
+ }
+
member.updatePassword(passwordEncoder.encode(newPassword));
}π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @Transactional | |
| public void updatePassword(String email, String currentPassword, String newPassword) { | |
| Member member = memberRepository.findByEmail(email) | |
| .orElseThrow(() -> new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€.")); | |
| if (!passwordEncoder.matches(currentPassword, member.getPassword())) { | |
| throw new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€."); | |
| } | |
| member.updatePassword(passwordEncoder.encode(newPassword)); | |
| } | |
| @Transactional | |
| public void updatePassword(String email, String currentPassword, String newPassword) { | |
| Member member = memberRepository.findByEmail(email) | |
| .orElseThrow(() -> new NotFoundException("μ¬μ©μλ₯Ό μ°Ύμ μ μμ΅λλ€.")); | |
| if (!passwordEncoder.matches(currentPassword, member.getPassword())) { | |
| throw new InvalidPasswordException("νμ¬ λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€."); | |
| } | |
| if (passwordEncoder.matches(newPassword, member.getPassword())) { | |
| throw new InvalidPasswordException("μ λΉλ°λ²νΈλ νμ¬ λΉλ°λ²νΈμ λ¬λΌμΌ ν©λλ€."); | |
| } | |
| member.updatePassword(passwordEncoder.encode(newPassword)); | |
| } |
| public void updateProfile(String nickname, String intro) { | ||
| this.nickname = nickname; | ||
| this.intro = intro; | ||
| } |
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.
π οΈ Refactor suggestion
νλ‘ν μ΄λ―Έμ§ URL μ λ°μ΄νΈ λ©μλ λλ½
νλ‘ν μ΄λ―Έμ§ URL νλκ° μ‘΄μ¬νμ§λ§ μ λ°μ΄νΈ λ©μλκ° λλ½λμμ΅λλ€.
public void updateProfile(String nickname, String intro) {
this.nickname = nickname;
this.intro = intro;
}
+
+ public void updateProfileImage(String profileImgUrl) {
+ this.profileImgUrl = profileImgUrl;
+ }Committable suggestion skipped: line range outside the PR's diff.
| @PutMapping | ||
| public ProfileResponse updateProfile( | ||
| @AuthenticationPrincipal MemberDetails memberDetails, | ||
| @RequestBody ProfileUpdateRequest request | ||
| ) { | ||
| Member updatedMember = memberService.updateProfile( | ||
| memberDetails.getMember().getEmail(), | ||
| request.nickname(), | ||
| request.intro() | ||
| ); | ||
| return ProfileResponse.of(updatedMember); | ||
| } |
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.
νλ‘ν μ λ°μ΄νΈ μλν¬μΈνΈμ μ ν¨μ± κ²μ¦ μΆκ° νμ
νλ‘ν μ λ°μ΄νΈ λ©μλμ μ λ ₯κ° μ ν¨μ± κ²μ¦μ΄ λλ½λμ΄ μμ΅λλ€. λλ€μμ κΈΈμ΄ μ νμ΄λ νΉμλ¬Έμ μ ν λ±μ κ²μ¦μ΄ νμν©λλ€.
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μν©λλ€:
@PutMapping
public ProfileResponse updateProfile(
@AuthenticationPrincipal MemberDetails memberDetails,
- @RequestBody ProfileUpdateRequest request
+ @RequestBody @Valid ProfileUpdateRequest request
) {ProfileUpdateRequestμ λ€μκ³Ό κ°μ μ μ½μ‘°κ±΄μ μΆκ°νμΈμ:
public record ProfileUpdateRequest(
@NotBlank(message = "λλ€μμ νμμ
λλ€")
@Size(min = 2, max = 20, message = "λλ€μμ 2-20μ μ¬μ΄μ¬μΌ ν©λλ€")
@Pattern(regexp = "^[a-zA-Z0-9κ°-ν£]*$", message = "λλ€μμ νκΈ, μλ¬Έ, μ«μλ§ κ°λ₯ν©λλ€")
String nickname,
@Size(max = 200, message = "μκΈ°μκ°λ 200μλ₯Ό μ΄κ³Όν μ μμ΅λλ€")
String intro
) {}| @PutMapping("/password") | ||
| public void updatePassword( | ||
| @AuthenticationPrincipal MemberDetails memberDetails, | ||
| @RequestBody PasswordUpdateRequest request | ||
| ) { | ||
| memberService.updatePassword( | ||
| memberDetails.getMember().getEmail(), | ||
| request.currentPassword(), | ||
| request.newPassword() | ||
| ); | ||
| } |
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.
λΉλ°λ²νΈ λ³κ²½ μλν¬μΈνΈμ 보μ κ°ν νμ
λΉλ°λ²νΈ λ³κ²½ λ‘μ§μ λ€μκ³Ό κ°μ 보μ κ°μ μ΄ νμν©λλ€:
- λΉλ°λ²νΈ 볡μ‘λ κ²μ¦
- μ΄μ λΉλ°λ²νΈμ λμΌνμ§ νμΈ
- μλ΅ μν μ½λ λͺ μ
λ€μκ³Ό κ°μ΄ μμ μ μ μν©λλ€:
@PutMapping("/password")
+ @ResponseStatus(HttpStatus.NO_CONTENT)
public void updatePassword(
@AuthenticationPrincipal MemberDetails memberDetails,
- @RequestBody PasswordUpdateRequest request
+ @RequestBody @Valid PasswordUpdateRequest request
) {PasswordUpdateRequestμ λ€μκ³Ό κ°μ μ μ½μ‘°κ±΄μ μΆκ°νμΈμ:
public record PasswordUpdateRequest(
@NotBlank(message = "νμ¬ λΉλ°λ²νΈλ νμμ
λλ€")
String currentPassword,
@NotBlank(message = "μ λΉλ°λ²νΈλ νμμ
λλ€")
@Pattern(
regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,}$",
message = "λΉλ°λ²νΈλ 8μ μ΄μμ΄λ©°, μλ¬Έμ, μ«μ, νΉμλ¬Έμλ₯Ό ν¬ν¨ν΄μΌ ν©λλ€"
)
String newPassword
) {}| .authorizeHttpRequests(auth -> auth | ||
| .requestMatchers( | ||
| "/","/api/auth/**", "/swagger-ui/**", "/v3/api-docs/**" | ||
| "/","/api/auth/**", "/api/profile/**", "/swagger-ui/**", "/v3/api-docs/**" |
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.
보μ μ€μ λ³κ²½ νμ: νλ‘ν μλν¬μΈνΈ μΈμ¦ νμ
νλ‘ν κ΄λ ¨ μλν¬μΈνΈ(/api/profile/**)λ₯Ό μΈμ¦ μμ΄ μ κ·Ό κ°λ₯νλλ‘ μ€μ ν κ²μ 보μμ μνν©λλ€. νλ‘ν μμ μ μΈμ¦λ μ¬μ©μλ§ κ°λ₯ν΄μΌ ν©λλ€.
λ€μκ³Ό κ°μ΄ μμ μ μ μν©λλ€:
.requestMatchers(
- "/","/api/auth/**", "/api/profile/**", "/swagger-ui/**", "/v3/api-docs/**"
+ "/","/api/auth/**", "/swagger-ui/**", "/v3/api-docs/**"
).permitAll()μΆκ°λ‘ νΉμ νλ‘ν μλν¬μΈνΈμ λν μΈλΆνλ κΆν μ€μ μ΄ νμν©λλ€:
.requestMatchers(HttpMethod.GET, "/api/profile/**").authenticated()
.requestMatchers(HttpMethod.PUT, "/api/profile/**").authenticated()
π κ΄λ ¨ μ΄μ
#32 μ¬μ©μ νλ‘ν μμ
β¨ κ³Όμ λ΄μ©
μ¬μμλ μμ μ νλ‘νμ μμ ν μ μμ΅λλ€.
μΆκ°μ μΌλ‘ ꡬνν΄μΌ λλ λΆλΆ
πΈ μ€ν¬λ¦°μ·(μ ν)
π λ νΌλ°μ€ (λλ μλ‘ μκ² λ λ΄μ©) νΉμ κΆκΈν μ¬νλ€
Summary by CodeRabbit
μλ‘μ΄ κΈ°λ₯
보μ κ°μ
/api/profile/**κ²½λ‘μ λν μ κ·Ό κΆν μ€μ μ λ°μ΄νΈκΈ°ν λ³κ²½μ¬ν