remove demo code

This commit is contained in:
2026-01-03 11:38:51 +01:00
parent 2f21dc4595
commit 9a7efa496f
38 changed files with 1535 additions and 1157 deletions

View File

@@ -1,10 +1,9 @@
import { Controller, Get, Post, Body, Query, Inject, Res } from '@nestjs/common';
import { Public } from './Public';
import { AuthService } from './AuthService';
import { LoginParamsDTO, SignupParamsDTO, AuthSessionDTO, ForgotPasswordDTO, ResetPasswordDTO, DemoLoginDTO } from './dtos/AuthDto';
import { LoginParamsDTO, SignupParamsDTO, AuthSessionDTO, ForgotPasswordDTO, ResetPasswordDTO } from './dtos/AuthDto';
import type { CommandResultDTO } from './presenters/CommandResultPresenter';
import type { Response } from 'express';
// ProductionGuard will be added if needed - for now we'll use environment check directly
@Public()
@Controller('auth')
@@ -58,13 +57,4 @@ export class AuthController {
async resetPassword(@Body() params: ResetPasswordDTO): Promise<{ message: string }> {
return this.authService.resetPassword(params);
}
@Post('demo-login')
async demoLogin(@Body() params: DemoLoginDTO): Promise<AuthSessionDTO> {
// Manual production check
if (process.env.NODE_ENV === 'production') {
throw new Error('Demo login is not available in production');
}
return this.authService.demoLogin(params);
}
}
}

View File

@@ -6,7 +6,6 @@ import { LogoutUseCase } from '@core/identity/application/use-cases/LogoutUseCas
import { SignupUseCase } from '@core/identity/application/use-cases/SignupUseCase';
import { ForgotPasswordUseCase } from '@core/identity/application/use-cases/ForgotPasswordUseCase';
import { ResetPasswordUseCase } from '@core/identity/application/use-cases/ResetPasswordUseCase';
import { DemoLoginUseCase } from '../../development/use-cases/DemoLoginUseCase';
import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort';
import type { IAuthRepository } from '@core/identity/domain/repositories/IAuthRepository';
import type { IMagicLinkRepository } from '@core/identity/domain/repositories/IMagicLinkRepository';
@@ -17,9 +16,7 @@ import type { LogoutResult } from '@core/identity/application/use-cases/LogoutUs
import type { SignupResult } from '@core/identity/application/use-cases/SignupUseCase';
import type { ForgotPasswordResult } from '@core/identity/application/use-cases/ForgotPasswordUseCase';
import type { ResetPasswordResult } from '@core/identity/application/use-cases/ResetPasswordUseCase';
import type { DemoLoginResult } from '../../development/use-cases/DemoLoginUseCase';
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
import type { IAdminUserRepository } from '@core/admin/domain/repositories/IAdminUserRepository';
import {
AUTH_REPOSITORY_TOKEN,
@@ -27,13 +24,11 @@ import {
USER_REPOSITORY_TOKEN,
MAGIC_LINK_REPOSITORY_TOKEN,
} from '../../persistence/identity/IdentityPersistenceTokens';
import { ADMIN_USER_REPOSITORY_TOKEN } from '../../persistence/admin/AdminPersistenceTokens';
import { AuthSessionPresenter } from './presenters/AuthSessionPresenter';
import { CommandResultPresenter } from './presenters/CommandResultPresenter';
import { ForgotPasswordPresenter } from './presenters/ForgotPasswordPresenter';
import { ResetPasswordPresenter } from './presenters/ResetPasswordPresenter';
import { DemoLoginPresenter } from './presenters/DemoLoginPresenter';
import { ConsoleMagicLinkNotificationAdapter } from '@adapters/notifications/ports/ConsoleMagicLinkNotificationAdapter';
// Define the tokens for dependency injection
@@ -45,13 +40,11 @@ export const SIGNUP_USE_CASE_TOKEN = 'SignupUseCase';
export const LOGOUT_USE_CASE_TOKEN = 'LogoutUseCase';
export const FORGOT_PASSWORD_USE_CASE_TOKEN = 'ForgotPasswordUseCase';
export const RESET_PASSWORD_USE_CASE_TOKEN = 'ResetPasswordUseCase';
export const DEMO_LOGIN_USE_CASE_TOKEN = 'DemoLoginUseCase';
export const AUTH_SESSION_OUTPUT_PORT_TOKEN = 'AuthSessionOutputPort';
export const COMMAND_RESULT_OUTPUT_PORT_TOKEN = 'CommandResultOutputPort';
export const FORGOT_PASSWORD_OUTPUT_PORT_TOKEN = 'ForgotPasswordOutputPort';
export const RESET_PASSWORD_OUTPUT_PORT_TOKEN = 'ResetPasswordOutputPort';
export const DEMO_LOGIN_OUTPUT_PORT_TOKEN = 'DemoLoginOutputPort';
export const MAGIC_LINK_NOTIFICATION_PORT_TOKEN = 'MagicLinkNotificationPort';
export const AuthProviders: Provider[] = [
@@ -98,7 +91,6 @@ export const AuthProviders: Provider[] = [
},
ForgotPasswordPresenter,
ResetPasswordPresenter,
DemoLoginPresenter,
{
provide: FORGOT_PASSWORD_OUTPUT_PORT_TOKEN,
useExisting: ForgotPasswordPresenter,
@@ -107,10 +99,6 @@ export const AuthProviders: Provider[] = [
provide: RESET_PASSWORD_OUTPUT_PORT_TOKEN,
useExisting: ResetPasswordPresenter,
},
{
provide: DEMO_LOGIN_OUTPUT_PORT_TOKEN,
useExisting: DemoLoginPresenter,
},
{
provide: MAGIC_LINK_NOTIFICATION_PORT_TOKEN,
useFactory: (logger: Logger) => new ConsoleMagicLinkNotificationAdapter(logger),
@@ -138,15 +126,4 @@ export const AuthProviders: Provider[] = [
) => new ResetPasswordUseCase(authRepo, magicLinkRepo, passwordHashing, logger, output),
inject: [AUTH_REPOSITORY_TOKEN, MAGIC_LINK_REPOSITORY_TOKEN, PASSWORD_HASHING_SERVICE_TOKEN, LOGGER_TOKEN, RESET_PASSWORD_OUTPUT_PORT_TOKEN],
},
{
provide: DEMO_LOGIN_USE_CASE_TOKEN,
useFactory: (
authRepo: IAuthRepository,
passwordHashing: IPasswordHashingService,
logger: Logger,
output: UseCaseOutputPort<DemoLoginResult>,
adminUserRepo: IAdminUserRepository,
) => new DemoLoginUseCase(authRepo, passwordHashing, logger, output, adminUserRepo),
inject: [AUTH_REPOSITORY_TOKEN, PASSWORD_HASHING_SERVICE_TOKEN, LOGGER_TOKEN, DEMO_LOGIN_OUTPUT_PORT_TOKEN, ADMIN_USER_REPOSITORY_TOKEN],
},
];
];

View File

@@ -42,16 +42,6 @@ class FakeResetPasswordPresenter {
}
}
class FakeDemoLoginPresenter {
private model: any = null;
reset() { this.model = null; }
present(model: any) { this.model = model; }
get responseModel() {
if (!this.model) throw new Error('Presenter not presented');
return this.model;
}
}
describe('AuthService - New Methods', () => {
describe('forgotPassword', () => {
it('should execute forgot password use case and return result', async () => {
@@ -71,12 +61,10 @@ describe('AuthService - New Methods', () => {
{ execute: vi.fn() } as any,
forgotPasswordUseCase as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
forgotPasswordPresenter as any,
new FakeResetPasswordPresenter() as any,
new FakeDemoLoginPresenter() as any,
);
const result = await service.forgotPassword({ email: 'test@example.com' });
@@ -97,12 +85,10 @@ describe('AuthService - New Methods', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn(async () => Result.err({ code: 'RATE_LIMIT_EXCEEDED', details: { message: 'Too many attempts' } })) } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeForgotPasswordPresenter() as any,
new FakeResetPasswordPresenter() as any,
new FakeDemoLoginPresenter() as any,
);
await expect(service.forgotPassword({ email: 'test@example.com' })).rejects.toThrow('Too many attempts');
@@ -127,12 +113,10 @@ describe('AuthService - New Methods', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
resetPasswordUseCase as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeForgotPasswordPresenter() as any,
resetPasswordPresenter as any,
new FakeDemoLoginPresenter() as any,
);
const result = await service.resetPassword({
@@ -148,6 +132,7 @@ describe('AuthService - New Methods', () => {
});
it('should throw error on use case failure', async () => {
const resetPasswordPresenter = new FakeResetPasswordPresenter();
const service = new AuthService(
{ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() } as any,
{ getCurrentSession: vi.fn(), createSession: vi.fn() } as any,
@@ -156,12 +141,10 @@ describe('AuthService - New Methods', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn(async () => Result.err({ code: 'INVALID_TOKEN', details: { message: 'Invalid token' } })) } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeForgotPasswordPresenter() as any,
new FakeResetPasswordPresenter() as any,
new FakeDemoLoginPresenter() as any,
resetPasswordPresenter as any,
);
await expect(
@@ -169,85 +152,4 @@ describe('AuthService - New Methods', () => {
).rejects.toThrow('Invalid token');
});
});
describe('demoLogin', () => {
it('should execute demo login use case and create session', async () => {
const demoLoginPresenter = new FakeDemoLoginPresenter();
const mockUser = {
getId: () => ({ value: 'demo-user-123' }),
getDisplayName: () => 'Alex Johnson',
getEmail: () => 'demo.driver@example.com',
getPrimaryDriverId: () => undefined,
};
const demoLoginUseCase = {
execute: vi.fn(async () => {
demoLoginPresenter.present({ user: mockUser });
return Result.ok(undefined);
}),
};
const identitySessionPort = {
getCurrentSession: vi.fn(),
createSession: vi.fn(async () => ({ token: 'demo-token-123' })),
};
const service = new AuthService(
{ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() } as any,
identitySessionPort as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
demoLoginUseCase as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeForgotPasswordPresenter() as any,
new FakeResetPasswordPresenter() as any,
demoLoginPresenter as any,
);
const result = await service.demoLogin({ role: 'driver' });
expect(demoLoginUseCase.execute).toHaveBeenCalledWith({ role: 'driver' });
expect(identitySessionPort.createSession).toHaveBeenCalledWith(
{
id: 'demo-user-123',
displayName: 'Alex Johnson',
email: 'demo.driver@example.com',
},
undefined
);
expect(result).toEqual({
token: 'demo-token-123',
user: {
userId: 'demo-user-123',
email: 'demo.driver@example.com',
displayName: 'Alex Johnson',
role: 'driver',
},
});
});
it('should throw error on use case failure', async () => {
const service = new AuthService(
{ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() } as any,
{ getCurrentSession: vi.fn(), createSession: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn(async () => Result.err({ code: 'DEMO_NOT_ALLOWED', details: { message: 'Demo not allowed' } })) } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeForgotPasswordPresenter() as any,
new FakeResetPasswordPresenter() as any,
new FakeDemoLoginPresenter() as any,
);
await expect(service.demoLogin({ role: 'driver' })).rejects.toThrow('Demo not allowed');
});
});
});

View File

@@ -40,12 +40,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.getCurrentSession()).resolves.toBeNull();
@@ -66,12 +64,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.getCurrentSession()).resolves.toEqual({
@@ -102,12 +98,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
authSessionPresenter as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
const session = await service.signupWithEmail({
@@ -138,12 +132,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(
@@ -173,12 +165,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
authSessionPresenter as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.loginWithEmail({ email: 'e3', password: 'p3' } as any)).resolves.toEqual({
@@ -206,12 +196,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.loginWithEmail({ email: 'e', password: 'p' } as any)).rejects.toThrow('Bad login');
@@ -226,12 +214,10 @@ describe('AuthService', () => {
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.loginWithEmail({ email: 'e', password: 'p' } as any)).rejects.toThrow('Login failed');
@@ -254,12 +240,10 @@ describe('AuthService', () => {
logoutUseCase as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
commandResultPresenter as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.logout()).resolves.toEqual({ success: true });
@@ -274,14 +258,12 @@ describe('AuthService', () => {
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as any)) } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
{ execute: vi.fn() } as any,
new FakeAuthSessionPresenter() as any,
new FakeCommandResultPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
new FakeAuthSessionPresenter() as any,
);
await expect(service.logout()).rejects.toThrow('Logout failed');
});
});
});

View File

@@ -23,11 +23,6 @@ import {
type ResetPasswordApplicationError,
type ResetPasswordInput,
} from '@core/identity/application/use-cases/ResetPasswordUseCase';
import {
DemoLoginUseCase,
type DemoLoginApplicationError,
type DemoLoginInput,
} from '../../development/use-cases/DemoLoginUseCase';
import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort';
@@ -36,7 +31,6 @@ import {
COMMAND_RESULT_OUTPUT_PORT_TOKEN,
FORGOT_PASSWORD_OUTPUT_PORT_TOKEN,
RESET_PASSWORD_OUTPUT_PORT_TOKEN,
DEMO_LOGIN_OUTPUT_PORT_TOKEN,
IDENTITY_SESSION_PORT_TOKEN,
LOGGER_TOKEN,
LOGIN_USE_CASE_TOKEN,
@@ -44,16 +38,14 @@ import {
SIGNUP_USE_CASE_TOKEN,
FORGOT_PASSWORD_USE_CASE_TOKEN,
RESET_PASSWORD_USE_CASE_TOKEN,
DEMO_LOGIN_USE_CASE_TOKEN,
} from './AuthProviders';
import type { AuthSessionDTO, AuthenticatedUserDTO } from './dtos/AuthDto';
import type { AuthSessionDTO } from './dtos/AuthDto';
import { LoginParamsDTO, SignupParamsDTO } from './dtos/AuthDto';
import { AuthSessionPresenter } from './presenters/AuthSessionPresenter';
import type { CommandResultDTO } from './presenters/CommandResultPresenter';
import { CommandResultPresenter } from './presenters/CommandResultPresenter';
import { ForgotPasswordPresenter } from './presenters/ForgotPasswordPresenter';
import { ResetPasswordPresenter } from './presenters/ResetPasswordPresenter';
import { DemoLoginPresenter } from './presenters/DemoLoginPresenter';
function mapApplicationErrorToMessage(error: { details?: { message?: string } } | undefined, fallback: string): string {
return error?.details?.message ?? fallback;
@@ -69,7 +61,6 @@ export class AuthService {
@Inject(LOGOUT_USE_CASE_TOKEN) private readonly logoutUseCase: LogoutUseCase,
@Inject(FORGOT_PASSWORD_USE_CASE_TOKEN) private readonly forgotPasswordUseCase: ForgotPasswordUseCase,
@Inject(RESET_PASSWORD_USE_CASE_TOKEN) private readonly resetPasswordUseCase: ResetPasswordUseCase,
@Inject(DEMO_LOGIN_USE_CASE_TOKEN) private readonly demoLoginUseCase: DemoLoginUseCase,
// TODO presenters must not be injected
@Inject(AUTH_SESSION_OUTPUT_PORT_TOKEN)
private readonly authSessionPresenter: AuthSessionPresenter,
@@ -79,8 +70,6 @@ export class AuthService {
private readonly forgotPasswordPresenter: ForgotPasswordPresenter,
@Inject(RESET_PASSWORD_OUTPUT_PORT_TOKEN)
private readonly resetPasswordPresenter: ResetPasswordPresenter,
@Inject(DEMO_LOGIN_OUTPUT_PORT_TOKEN)
private readonly demoLoginPresenter: DemoLoginPresenter,
) {}
async getCurrentSession(): Promise<AuthSessionDTO | null> {
@@ -89,13 +78,16 @@ export class AuthService {
const coreSession = await this.identitySessionPort.getCurrentSession();
if (!coreSession) return null;
const userRole = coreSession.user.role;
const role = userRole ? (userRole as AuthSessionDTO['user']['role']) : undefined;
return {
token: coreSession.token,
user: {
userId: coreSession.user.id,
email: coreSession.user.email ?? '',
displayName: coreSession.user.displayName,
role: coreSession.user.role as any,
...(role !== undefined ? { role } : {}),
},
};
}
@@ -275,57 +267,4 @@ export class AuthService {
return this.resetPasswordPresenter.responseModel;
}
async demoLogin(params: { role: 'driver' | 'sponsor' | 'league-owner' | 'league-steward' | 'league-admin' | 'system-owner' | 'super-admin', rememberMe?: boolean }): Promise<AuthSessionDTO> {
this.logger.debug(`[AuthService] Attempting demo login for role: ${params.role}`);
this.demoLoginPresenter.reset();
const input: DemoLoginInput = {
role: params.role,
};
const result = await this.demoLoginUseCase.execute(input);
if (result.isErr()) {
const error = result.unwrapErr() as DemoLoginApplicationError;
throw new Error(mapApplicationErrorToMessage(error, 'Demo login failed'));
}
const user = this.demoLoginPresenter.responseModel.user;
const primaryDriverId = user.getPrimaryDriverId();
// Use primaryDriverId for session if available, otherwise fall back to userId
const sessionId = primaryDriverId ?? user.getId().value;
const sessionOptions = params.rememberMe !== undefined
? { rememberMe: params.rememberMe }
: undefined;
const session = await this.identitySessionPort.createSession(
{
id: sessionId,
displayName: user.getDisplayName(),
email: user.getEmail() ?? '',
role: params.role,
},
sessionOptions
);
const userDTO: AuthenticatedUserDTO = {
userId: user.getId().value,
email: user.getEmail() ?? '',
displayName: user.getDisplayName(),
role: params.role,
};
if (primaryDriverId !== undefined) {
userDTO.primaryDriverId = primaryDriverId;
}
return {
token: session.token,
user: userDTO,
};
}
}

View File

@@ -1,18 +0,0 @@
import { CanActivate, ExecutionContext, Injectable, ForbiddenException } from '@nestjs/common';
@Injectable()
export class ProductionGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const path = request.path;
// Block demo login in production
if (path === '/auth/demo-login' || path === '/api/auth/demo-login') {
if (process.env.NODE_ENV === 'production') {
throw new ForbiddenException('Demo login is not available in production');
}
}
return true;
}
}

View File

@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsString, MinLength, IsIn, IsOptional } from 'class-validator';
import { IsEmail, IsString, MinLength, IsOptional } from 'class-validator';
export class AuthenticatedUserDTO {
@ApiProperty()
@@ -98,15 +98,4 @@ export class ResetPasswordDTO {
@IsString()
@MinLength(8)
newPassword!: string;
}
export class DemoLoginDTO {
@ApiProperty({ enum: ['driver', 'sponsor', 'league-owner', 'league-steward', 'league-admin', 'system-owner', 'super-admin'] })
@IsString()
@IsIn(['driver', 'sponsor', 'league-owner', 'league-steward', 'league-admin', 'system-owner', 'super-admin'])
role!: 'driver' | 'sponsor' | 'league-owner' | 'league-steward' | 'league-admin' | 'system-owner' | 'super-admin';
@ApiProperty({ required: false, default: false })
@IsOptional()
rememberMe?: boolean;
}
}

View File

@@ -1,23 +0,0 @@
import { Injectable } from '@nestjs/common';
import { UseCaseOutputPort } from '@core/shared/application';
import { DemoLoginResult } from '../../../development/use-cases/DemoLoginUseCase';
@Injectable()
export class DemoLoginPresenter implements UseCaseOutputPort<DemoLoginResult> {
private _responseModel: DemoLoginResult | null = null;
present(result: DemoLoginResult): void {
this._responseModel = result;
}
get responseModel(): DemoLoginResult {
if (!this._responseModel) {
throw new Error('DemoLoginPresenter: No response model available');
}
return this._responseModel;
}
reset(): void {
this._responseModel = null;
}
}