- PasswordForgotRequestDto, PasswordResetRequestDto 생성 - IAuthService에 ForgotPasswordAsync, ResetPasswordAsync 추가 - ForgotPasswordAsync: UUID 토큰 생성 → ITokenStore 저장(30분) → 이메일 발송 - ResetPasswordAsync: 토큰 검증 → BCrypt 해싱 → 비밀번호 저장 - PasswordController 생성 (v1/in/account/password) - 보안: forgot에서 이메일 미존재 시에도 동일한 성공 응답
47 lines
1.7 KiB
C#
47 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using SPMS.Application.DTOs.Account;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Domain.Common;
|
|
|
|
namespace SPMS.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1/in/account/password")]
|
|
[ApiExplorerSettings(GroupName = "account")]
|
|
[AllowAnonymous]
|
|
public class PasswordController : ControllerBase
|
|
{
|
|
private readonly IAuthService _authService;
|
|
|
|
public PasswordController(IAuthService authService)
|
|
{
|
|
_authService = authService;
|
|
}
|
|
|
|
[HttpPost("forgot")]
|
|
[SwaggerOperation(
|
|
Summary = "비밀번호 찾기",
|
|
Description = "등록된 이메일로 비밀번호 재설정 토큰을 발송합니다. 보안을 위해 이메일 존재 여부와 관계없이 동일한 응답을 반환합니다.")]
|
|
[SwaggerResponse(200, "재설정 메일 발송 완료")]
|
|
[SwaggerResponse(400, "잘못된 요청")]
|
|
public async Task<IActionResult> ForgotPasswordAsync([FromBody] PasswordForgotRequestDto request)
|
|
{
|
|
await _authService.ForgotPasswordAsync(request);
|
|
return Ok(ApiResponse.Success());
|
|
}
|
|
|
|
[HttpPost("reset")]
|
|
[SwaggerOperation(
|
|
Summary = "비밀번호 재설정",
|
|
Description = "이메일로 받은 재설정 토큰과 새 비밀번호로 비밀번호를 재설정합니다.")]
|
|
[SwaggerResponse(200, "비밀번호 재설정 성공")]
|
|
[SwaggerResponse(400, "토큰 불일치 또는 만료")]
|
|
public async Task<IActionResult> ResetPasswordAsync([FromBody] PasswordResetRequestDto request)
|
|
{
|
|
await _authService.ResetPasswordAsync(request);
|
|
return Ok(ApiResponse.Success());
|
|
}
|
|
}
|