feat: 이메일 중복 체크 API 구현 (#58)

POST /v1/in/auth/email/check 엔드포인트 추가.
기존 EmailExistsAsync 활용하여 이메일 사용 가능 여부 반환.
This commit is contained in:
SEAN 2026-02-10 10:23:25 +09:00
parent 94b0787bf8
commit 5d49a2ce49
5 changed files with 45 additions and 0 deletions

View File

@ -33,6 +33,19 @@ public class AuthController : ControllerBase
return Ok(ApiResponse<SignupResponseDto>.Success(result, "회원가입 완료. 이메일 인증이 필요합니다.")); return Ok(ApiResponse<SignupResponseDto>.Success(result, "회원가입 완료. 이메일 인증이 필요합니다."));
} }
[HttpPost("email/check")]
[AllowAnonymous]
[SwaggerOperation(
Summary = "이메일 중복 체크",
Description = "회원가입 전 이메일 사용 가능 여부를 확인합니다.")]
[SwaggerResponse(200, "이메일 중복 체크 성공", typeof(ApiResponse<EmailCheckResponseDto>))]
[SwaggerResponse(400, "잘못된 요청")]
public async Task<IActionResult> CheckEmailAsync([FromBody] EmailCheckRequestDto request)
{
var result = await _authService.CheckEmailAsync(request);
return Ok(ApiResponse<EmailCheckResponseDto>.Success(result));
}
[HttpPost("login")] [HttpPost("login")]
[AllowAnonymous] [AllowAnonymous]
[SwaggerOperation( [SwaggerOperation(

View File

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace SPMS.Application.DTOs.Auth;
public class EmailCheckRequestDto
{
[Required(ErrorMessage = "이메일은 필수입니다.")]
[EmailAddress(ErrorMessage = "올바른 이메일 형식이 아닙니다.")]
public string Email { get; set; } = string.Empty;
}

View File

@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace SPMS.Application.DTOs.Auth;
public class EmailCheckResponseDto
{
public string Email { get; set; } = string.Empty;
[JsonPropertyName("is_available")]
public bool IsAvailable { get; set; }
}

View File

@ -9,4 +9,5 @@ public interface IAuthService
Task<TokenRefreshResponseDto> RefreshTokenAsync(TokenRefreshRequestDto request); Task<TokenRefreshResponseDto> RefreshTokenAsync(TokenRefreshRequestDto request);
Task LogoutAsync(long adminId); Task LogoutAsync(long adminId);
Task ChangePasswordAsync(long adminId, ChangePasswordRequestDto request); Task ChangePasswordAsync(long adminId, ChangePasswordRequestDto request);
Task<EmailCheckResponseDto> CheckEmailAsync(EmailCheckRequestDto request);
} }

View File

@ -215,4 +215,14 @@ public class AuthService : IAuthService
_adminRepository.Update(admin); _adminRepository.Update(admin);
await _unitOfWork.SaveChangesAsync(); await _unitOfWork.SaveChangesAsync();
} }
public async Task<EmailCheckResponseDto> CheckEmailAsync(EmailCheckRequestDto request)
{
var exists = await _adminRepository.EmailExistsAsync(request.Email);
return new EmailCheckResponseDto
{
Email = request.Email,
IsAvailable = !exists
};
}
} }