Skip to content

Conversation

@ohyuchan123
Copy link
Member

@ohyuchan123 ohyuchan123 commented Jan 15, 2025

πŸ“Œ κ΄€λ ¨ 이슈

#32 μ‚¬μš©μž ν”„λ‘œν•„ μˆ˜μ •

✨ 과제 λ‚΄μš©

μ‚¬μš”μžλŠ” μžμ‹ μ˜ ν”„λ‘œν•„μ„ μˆ˜μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μΆ”κ°€μ μœΌλ‘œ κ΅¬ν˜„ν•΄μ•Ό λ˜λŠ” λΆ€λΆ„

  • μ‚¬μš©μž ν”„λ‘œν•„ 이미지 등둝 및 μˆ˜μ •
  • μ‚¬μš©μžκ°€ λΉ„λ°€λ²ˆν˜Έλ₯Ό λ³€κ²½ν–ˆμ„ 경우 κ²½κ³  문ꡬ와 ν•¨κ»˜ κ°•μ œ λ‘œκ·Έμ•„μ›ƒ

πŸ“Έ μŠ€ν¬λ¦°μƒ·(선택)

image image

πŸ“š 레퍼런슀 (λ˜λŠ” μƒˆλ‘œ μ•Œκ²Œ 된 λ‚΄μš©) ν˜Ήμ€ κΆκΈˆν•œ 사항듀

Summary by CodeRabbit

  • μƒˆλ‘œμš΄ κΈ°λŠ₯

    • μ‚¬μš©μž ν”„λ‘œν•„ μ—…λ°μ΄νŠΈ κΈ°λŠ₯ μΆ”κ°€
    • μ‚¬μš©μž λΉ„λ°€λ²ˆν˜Έ λ³€κ²½ κΈ°λŠ₯ μΆ”κ°€
  • λ³΄μ•ˆ κ°œμ„ 

    • /api/profile/** κ²½λ‘œμ— λŒ€ν•œ μ ‘κ·Ό κΆŒν•œ μ„€μ • μ—…λ°μ΄νŠΈ
  • 기타 변경사항

    • ν”„λ‘œν•„ 및 λΉ„λ°€λ²ˆν˜Έ 변경을 μœ„ν•œ μƒˆλ‘œμš΄ 데이터 전솑 객체(DTO) 생성
    • μ‚¬μš©μž 정보 관리 μ„œλΉ„μŠ€ κ°œμ„ 

@ohyuchan123 ohyuchan123 added πŸ”¨ Refactor μ½”λ“œ λ¦¬νŒ©ν† λ§ ✨ Feature κΈ°λŠ₯ 개발 labels Jan 15, 2025
@ohyuchan123 ohyuchan123 self-assigned this Jan 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2025

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 3297bf8 and 63cfeb7.

πŸ“’ Files selected for processing (4)
  • 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/service/MemberService.java (2 hunks)

μ›Œν¬μŠ€λ£¨

이 ν’€ λ¦¬ν€˜μŠ€νŠΈλŠ” μ‚¬μš©μž ν”„λ‘œν•„ 및 λΉ„λ°€λ²ˆν˜Έ μ—…λ°μ΄νŠΈ κΈ°λŠ₯을 μΆ”κ°€ν•˜λŠ” λ³€κ²½ 사항을 ν¬ν•¨ν•©λ‹ˆλ‹€. λ³΄μ•ˆ κ΅¬μ„±μ—μ„œ /api/profile/** κ²½λ‘œμ— λŒ€ν•œ μ ‘κ·Ό κΆŒν•œμ„ ν—ˆμš©ν•˜λ„λ‘ μˆ˜μ •λ˜μ—ˆμœΌλ©°, ν”„λ‘œν•„ μ»¨νŠΈλ‘€λŸ¬μ— μƒˆλ‘œμš΄ λ©”μ„œλ“œκ°€ λ„μž…λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ‚¬μš©μž ν”„λ‘œν•„ 및 λΉ„λ°€λ²ˆν˜Έ μ—…λ°μ΄νŠΈλ₯Ό μœ„ν•œ μš”μ²­ DTO와 μ„œλΉ„μŠ€ 둜직이 κ΅¬ν˜„λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

λ³€κ²½ 사항

파일 λ³€κ²½ μš”μ•½
SecurityConfig.java /api/profile/** κ²½λ‘œμ— λŒ€ν•œ 인증 μ—†λŠ” μ ‘κ·Ό ν—ˆμš©
ProfileController.java ν”„λ‘œν•„ 및 λΉ„λ°€λ²ˆν˜Έ μ—…λ°μ΄νŠΈ λ©”μ„œλ“œ μΆ”κ°€
PasswordUpdateRequest.java λΉ„λ°€λ²ˆν˜Έ μ—…λ°μ΄νŠΈ μš”μ²­ DTO 생성
ProfileUpdateRequest.java ν”„λ‘œν•„ μ—…λ°μ΄νŠΈ μš”μ²­ DTO 생성
Member.java ν”„λ‘œν•„ 및 λΉ„λ°€λ²ˆν˜Έ μ—…λ°μ΄νŠΈ λ©”μ„œλ“œ μΆ”κ°€
MemberService.java ν”„λ‘œν•„ 및 λΉ„λ°€λ²ˆν˜Έ μ—…λ°μ΄νŠΈ μ„œλΉ„μŠ€ 둜직 κ΅¬ν˜„

μ‹œν€€μŠ€ λ‹€μ΄μ–΄κ·Έλž¨

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: ν”„λ‘œν•„ 응닡
Loading

κ΄€λ ¨ κ°€λŠ₯μ„± μžˆλŠ” PR

  • πŸ”€ Profile SearchΒ #37: μ‚¬μš©μž ν”„λ‘œν•„ 관리와 κ΄€λ ¨λœ 컨트둀러 λ©”μ„œλ“œ μΆ”κ°€

ν† λΌμ˜ μ‹œ

🐰 ν”„λ‘œν•„ μˆ˜μ •μ˜ μΆ€

λ³΄μ•ˆ λ¬Έ 열리고
μƒˆλ‘œμš΄ κΈ°λŠ₯ λ°˜μ§μ—¬
λ‹‰λ„€μž„κ³Ό λΉ„λ°€λ²ˆν˜Έ
자유둭게 λ°”κΎΈλ„€
μ½”λ“œμ˜ 토끼 μΆ€μΆ”μž! πŸ•Ί


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?

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 22fa66a and 3297bf8.

πŸ“’ 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)

Comment on lines 3 to 6
public record ProfileUpdateRequest(
String nickname,
String intro
) {} No newline at end of file
Copy link

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.

Comment on lines 3 to 6
public record PasswordUpdateRequest(
String currentPassword,
String newPassword
) {}
Copy link

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.

Suggested change
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
) {}

Comment on lines 33 to 35
if (!passwordEncoder.matches(currentPassword, member.getPassword())) {
throw new NotFoundException("μ‚¬μš©μžλ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

λ³΄μ•ˆ κ°œμ„ : λΉ„λ°€λ²ˆν˜Έ 였λ₯˜μ™€ μ‚¬μš©μž μ—†μŒμ— λŒ€ν•œ μ˜ˆμ™Έ ꡬ뢄 ν•„μš”

ν˜„μž¬ κ΅¬ν˜„μ€ μ‚¬μš©μžλ₯Ό 찾을 수 μ—†λŠ” κ²½μš°μ™€ λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠλŠ” κ²½μš°μ— λ™μΌν•œ μ˜ˆμ™Έλ₯Ό λ°œμƒμ‹œν‚΅λ‹ˆλ‹€. μ΄λŠ” λ³΄μ•ˆμƒ μ’‹μ§€ μ•Šμ€ λ°©μ‹μž…λ‹ˆλ‹€.

-        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.

Comment on lines 28 to 38
@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));
}
Copy link

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.

Suggested change
@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));
}

Comment on lines +54 to +57
public void updateProfile(String nickname, String intro) {
this.nickname = nickname;
this.intro = intro;
}
Copy link

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.

Comment on lines 25 to 36
@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);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

ν”„λ‘œν•„ μ—…λ°μ΄νŠΈ μ—”λ“œν¬μΈνŠΈμ˜ μœ νš¨μ„± 검증 μΆ”κ°€ ν•„μš”

ν”„λ‘œν•„ μ—…λ°μ΄νŠΈ λ©”μ„œλ“œμ— μž…λ ₯κ°’ μœ νš¨μ„± 검증이 λˆ„λ½λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. λ‹‰λ„€μž„μ˜ 길이 μ œν•œμ΄λ‚˜ 특수문자 μ œν•œ λ“±μ˜ 검증이 ν•„μš”ν•©λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같이 μˆ˜μ •ν•˜λŠ” 것을 μ œμ•ˆν•©λ‹ˆλ‹€:

    @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
) {}

Comment on lines 38 to 48
@PutMapping("/password")
public void updatePassword(
@AuthenticationPrincipal MemberDetails memberDetails,
@RequestBody PasswordUpdateRequest request
) {
memberService.updatePassword(
memberDetails.getMember().getEmail(),
request.currentPassword(),
request.newPassword()
);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

λΉ„λ°€λ²ˆν˜Έ λ³€κ²½ μ—”λ“œν¬μΈνŠΈμ˜ λ³΄μ•ˆ κ°•ν™” ν•„μš”

λΉ„λ°€λ²ˆν˜Έ λ³€κ²½ λ‘œμ§μ— λ‹€μŒκ³Ό 같은 λ³΄μ•ˆ κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€:

  1. λΉ„λ°€λ²ˆν˜Έ λ³΅μž‘λ„ 검증
  2. 이전 λΉ„λ°€λ²ˆν˜Έμ™€ λ™μΌν•œμ§€ 확인
  3. 응닡 μƒνƒœ μ½”λ“œ λͺ…μ‹œ

λ‹€μŒκ³Ό 같이 μˆ˜μ •μ„ μ œμ•ˆν•©λ‹ˆλ‹€:

    @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/**"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

λ³΄μ•ˆ μ„€μ • λ³€κ²½ ν•„μš”: ν”„λ‘œν•„ μ—”λ“œν¬μΈνŠΈ 인증 ν•„μˆ˜

ν”„λ‘œν•„ κ΄€λ ¨ μ—”λ“œν¬μΈνŠΈ(/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()

@ohyuchan123 ohyuchan123 merged commit aa3dcfa into develop Jan 15, 2025
2 checks passed
@ohyuchan123 ohyuchan123 changed the title Profile Modify πŸ”€ Profile Modify Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature κΈ°λŠ₯ 개발 πŸ”¨ Refactor μ½”λ“œ λ¦¬νŒ©ν† λ§

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants