refactor auth module

This commit is contained in:
2025-12-21 23:33:42 +01:00
parent b639483187
commit 44ed8db555

View File

@@ -4,14 +4,14 @@ import type { Logger } from '@core/shared/application';
import {
LoginUseCase,
type LoginInput,
type LoginApplicationError,
type LoginInput,
} from '@core/identity/application/use-cases/LoginUseCase';
import { LogoutUseCase, type LogoutApplicationError } from '@core/identity/application/use-cases/LogoutUseCase';
import {
SignupUseCase,
type SignupInput,
type SignupApplicationError,
type SignupInput,
} from '@core/identity/application/use-cases/SignupUseCase';
import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort';
@@ -43,6 +43,7 @@ export class AuthService {
@Inject(LOGIN_USE_CASE_TOKEN) private readonly loginUseCase: LoginUseCase,
@Inject(SIGNUP_USE_CASE_TOKEN) private readonly signupUseCase: SignupUseCase,
@Inject(LOGOUT_USE_CASE_TOKEN) private readonly logoutUseCase: LogoutUseCase,
// TODO presenters must not be injected
@Inject(AUTH_SESSION_OUTPUT_PORT_TOKEN)
private readonly authSessionPresenter: AuthSessionPresenter,
@Inject(COMMAND_RESULT_OUTPUT_PORT_TOKEN)
@@ -50,13 +51,12 @@ export class AuthService {
) {}
async getCurrentSession(): Promise<AuthSessionDTO | null> {
// TODO must call a use case (out of scope here)
// TODO must call a use case
this.logger.debug('[AuthService] Attempting to get current session.');
const coreSession = await this.identitySessionPort.getCurrentSession();
if (!coreSession) return null;
// Avoid service-level mapping; in this module we only support presenter-based output for use cases.
// For now return a minimal session shape.
// TODO!!
return {
token: coreSession.token,
user: {
@@ -133,7 +133,7 @@ export class AuthService {
this.commandResultPresenter.reset();
const result = await this.logoutUseCase.execute(undefined);
const result = await this.logoutUseCase.execute({});
if (result.isErr()) {
const error = result.unwrapErr() as LogoutApplicationError;