52 lines
2.3 KiB
Java
52 lines
2.3 KiB
Java
package com.zioinfo.cms.auth;
|
|
|
|
import com.zioinfo.cms.auth.dto.AuthHelperResult;
|
|
import com.zioinfo.cms.auth.dto.FindIdRequest;
|
|
import com.zioinfo.cms.auth.dto.FindIdResponse;
|
|
import com.zioinfo.cms.auth.dto.ResetPasswordRequest;
|
|
import com.zioinfo.cms.auth.dto.SignupRequest;
|
|
import com.zioinfo.cms.common.ApiResponse;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
/**
|
|
* 로그인 보조 기능 3종(UIWS auth 패턴 이식) — 회원가입 / 아이디찾기 / 비밀번호 초기화.
|
|
*
|
|
* <p>base path {@code /api/auth} (SecurityConfig permitAll — 로그인 전 무인증 접근).
|
|
* 대상은 CMS 관리자/운영자 계정(cms_user) — UGC 고객회원(cms_member)과 구분된다.
|
|
* <ul>
|
|
* <li>회원가입: 승인 대기(approved=false) 상태로 등록 → SUPERADMIN 승인 전 로그인 차단</li>
|
|
* <li>아이디찾기: displayName+email 매칭, username 부분 마스킹 반환</li>
|
|
* <li>비번초기화: username+email 검증 → 임시비번 BCrypt 저장 + 메일/로그 발송(응답에 비번 미포함)</li>
|
|
* </ul>
|
|
* 보안 불변규칙: 임시비번·자격증명·계정 존재여부를 응답/로그 메시지에 노출하지 않는다.
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/auth")
|
|
@RequiredArgsConstructor
|
|
public class AuthHelperController {
|
|
|
|
private final AuthService authService;
|
|
|
|
/** 운영자 회원가입(승인 대기 INSERT). */
|
|
@PostMapping("/signup")
|
|
public ApiResponse<AuthHelperResult> signup(@RequestBody SignupRequest req) {
|
|
return ApiResponse.ok(authService.signup(req));
|
|
}
|
|
|
|
/** 아이디 찾기(이메일+이름 매칭, 마스킹 반환). */
|
|
@PostMapping("/find-id")
|
|
public ApiResponse<FindIdResponse> findId(@RequestBody FindIdRequest req) {
|
|
return ApiResponse.ok(authService.findId(req));
|
|
}
|
|
|
|
/** 비밀번호 초기화(검증 → 임시비번 BCrypt + 메일/로그). */
|
|
@PostMapping("/reset-password")
|
|
public ApiResponse<AuthHelperResult> resetPassword(@RequestBody ResetPasswordRequest req) {
|
|
return ApiResponse.ok(authService.resetPassword(req));
|
|
}
|
|
}
|