- ITokenStore, IEmailService 인터페이스 정의 - InMemoryTokenStore (IMemoryCache 기반), ConsoleEmailService (로그 출력) 구현 - SignupAsync에 6자리 인증 코드 생성/저장/발송 로직 추가 - VerifyEmailAsync 구현 (코드 검증 → EmailVerified 업데이트) - POST /v1/in/auth/email/verify 엔드포인트 추가 - DI 등록 (ITokenStore, IEmailService, MemoryCache)
44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Domain.Interfaces;
|
|
using SPMS.Infrastructure.Auth;
|
|
using SPMS.Infrastructure.Persistence;
|
|
using SPMS.Infrastructure.Persistence.Repositories;
|
|
using SPMS.Infrastructure.Security;
|
|
using SPMS.Infrastructure.Services;
|
|
|
|
namespace SPMS.Infrastructure;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddInfrastructure(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration)
|
|
{
|
|
// DbContext
|
|
var connectionString = configuration.GetConnectionString("DefaultConnection");
|
|
services.AddDbContext<AppDbContext>(options =>
|
|
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
|
|
|
// UnitOfWork & Repositories
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
|
services.AddScoped<IServiceRepository, ServiceRepository>();
|
|
services.AddScoped<IAdminRepository, AdminRepository>();
|
|
|
|
// External Services
|
|
services.AddScoped<IJwtService, JwtService>();
|
|
services.AddSingleton<IE2EEService, E2EEService>();
|
|
services.AddSingleton<ICredentialEncryptionService, CredentialEncryptionService>();
|
|
|
|
// Token Store & Email Service
|
|
services.AddMemoryCache();
|
|
services.AddSingleton<ITokenStore, InMemoryTokenStore>();
|
|
services.AddSingleton<IEmailService, ConsoleEmailService>();
|
|
|
|
return services;
|
|
}
|
|
}
|