- ITokenStore, IEmailService 인터페이스 정의 - InMemoryTokenStore (IMemoryCache 기반), ConsoleEmailService (로그 출력) 구현 - SignupAsync에 6자리 인증 코드 생성/저장/발송 로직 추가 - VerifyEmailAsync 구현 (코드 검증 → EmailVerified 업데이트) - POST /v1/in/auth/email/verify 엔드포인트 추가 - DI 등록 (ITokenStore, IEmailService, MemoryCache)
33 lines
723 B
C#
33 lines
723 B
C#
using Microsoft.Extensions.Caching.Memory;
|
|
using SPMS.Application.Interfaces;
|
|
|
|
namespace SPMS.Infrastructure.Services;
|
|
|
|
public class InMemoryTokenStore : ITokenStore
|
|
{
|
|
private readonly IMemoryCache _cache;
|
|
|
|
public InMemoryTokenStore(IMemoryCache cache)
|
|
{
|
|
_cache = cache;
|
|
}
|
|
|
|
public Task StoreAsync(string key, string value, TimeSpan expiry)
|
|
{
|
|
_cache.Set(key, value, expiry);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task<string?> GetAsync(string key)
|
|
{
|
|
_cache.TryGetValue(key, out string? value);
|
|
return Task.FromResult(value);
|
|
}
|
|
|
|
public Task RemoveAsync(string key)
|
|
{
|
|
_cache.Remove(key);
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|