[volume-1] 회원가입, 내 정보 조회, 비밀번호 수정 구현 #23
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📌 Summary
🧭 Context & Decision
문제 정의
선택지와 결정
spring-security-crypto의 BCryptPasswordEncoder 사용🏗️ Design Overview
변경 범위
commerce-api,modules/jpa(testFixtures)User,UserRepository,UserServiceUserJpaRepository,UserRepositoryImplUserFacade,UserInfoUserV1Controller,UserV1Dto,UserV1ApiSpecAuthenticatedUser,AuthenticatedUserArgumentResolver,WebMvcConfigUserTest(47건),UserServiceIntegrationTest(9건),UserV1ApiE2ETest(12건)주요 컴포넌트 책임
User: 사용자 엔티티 — 필드 검증, BCrypt 암호화, 비밀번호 매칭, 이름 마스킹UserService: 회원가입(중복 체크), 조회, 인증, 비밀번호 변경 도메인 로직UserFacade: Application 계층에서 UserService 조합 → UserInfo 반환AuthenticatedUserArgumentResolver: X-Loopers-LoginId/LoginPw 헤더 → AuthenticatedUser 변환UserV1Controller: REST API 엔드포인트 (POST /users, GET /users/me, PATCH /users/me/password)🔁 Flow Diagram
회원가입 (POST /api/v1/users)
sequenceDiagram autonumber participant Client participant UserV1Controller participant UserFacade participant UserService participant UserRepository participant User participant DB Client->>UserV1Controller: POST /api/v1/users {loginId, password, name, birthDate, email} UserV1Controller->>UserFacade: register(...) UserFacade->>UserService: register(...) UserService->>UserRepository: existsByLoginId(loginId) UserRepository->>DB: SELECT EXISTS DB-->>UserRepository: result alt loginId 중복 UserService-->>Client: 409 CONFLICT else loginId 사용 가능 UserService->>User: new User(...) — 필드 검증 + BCrypt 암호화 UserService->>UserRepository: save(user) UserRepository->>DB: INSERT DB-->>UserRepository: User (with ID) UserRepository-->>UserService: User UserService-->>UserFacade: User UserFacade-->>UserV1Controller: UserInfo UserV1Controller-->>Client: 201 Created {userId} end내 정보 조회 (GET /api/v1/users/me)
sequenceDiagram autonumber participant Client participant ArgumentResolver participant UserV1Controller participant UserFacade participant UserService participant UserRepository participant DB Client->>ArgumentResolver: GET /api/v1/users/me (X-Loopers-LoginId, X-Loopers-LoginPw) alt 헤더 누락 ArgumentResolver-->>Client: 400 Bad Request else 헤더 존재 ArgumentResolver->>UserV1Controller: AuthenticatedUser(loginId, password) UserV1Controller->>UserFacade: getMyInfo(loginId, password) UserFacade->>UserService: authenticate(loginId, password) UserService->>UserRepository: findByLoginId(loginId) UserRepository->>DB: SELECT alt 사용자 없음 UserService-->>Client: 401 USER_NOT_FOUND else 비밀번호 불일치 UserService-->>Client: 401 PASSWORD_MISMATCH else 인증 성공 UserService-->>UserFacade: User UserFacade-->>UserV1Controller: UserInfo (maskedName) UserV1Controller-->>Client: 200 OK {loginId, name(마스킹), birthDate, email} end end비밀번호 변경 (PATCH /api/v1/users/me/password)
sequenceDiagram autonumber participant Client participant ArgumentResolver participant UserV1Controller participant UserFacade participant UserService participant User participant DB Client->>ArgumentResolver: PATCH /api/v1/users/me/password (Headers + Body) alt 헤더 누락 ArgumentResolver-->>Client: 400 Bad Request else 헤더 존재 ArgumentResolver->>UserV1Controller: AuthenticatedUser + ChangePasswordRequest UserV1Controller->>UserFacade: changePassword(loginId, currentPw, newPw) UserFacade->>UserService: changePassword(loginId, currentPw, newPw) UserService->>UserService: authenticate(loginId, currentPw) alt 인증 실패 UserService-->>Client: 401 Unauthorized else 인증 성공 UserService->>User: changePassword(newPw) alt 현재 비밀번호와 동일 or 규칙 위반 User-->>Client: 400 Bad Request else 변경 성공 Note over User: BCrypt 재암호화 UserService->>DB: UPDATE (dirty checking) UserV1Controller-->>Client: 200 OK {message} end end end