This commit is contained in:
2025-12-14 18:11:59 +01:00
parent acc15e8d8d
commit 217337862c
91 changed files with 5919 additions and 1999 deletions

View File

@@ -1,5 +1,6 @@
import { Result } from '../../../shared/result/Result';
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import type { ILogger } from '../../../shared/src/logging/ILogger';
/**
* Use case for clearing the user's session (logout).
@@ -8,7 +9,10 @@ import type { AuthenticationServicePort } from '../ports/AuthenticationServicePo
* the user out. The next automation attempt will require re-authentication.
*/
export class ClearSessionUseCase {
constructor(private readonly authService: AuthenticationServicePort) {}
constructor(
private readonly authService: AuthenticationServicePort,
private readonly logger: ILogger, // Inject ILogger
) {}
/**
* Execute the session clearing.
@@ -16,6 +20,28 @@ export class ClearSessionUseCase {
* @returns Result indicating success or failure
*/
async execute(): Promise<Result<void>> {
return this.authService.clearSession();
this.logger.debug('Attempting to clear user session.', {
useCase: 'ClearSessionUseCase'
});
try {
const result = await this.authService.clearSession();
if (result.isSuccess) {
this.logger.info('User session cleared successfully.', {
useCase: 'ClearSessionUseCase'
});
} else {
this.logger.warn('Failed to clear user session.', {
useCase: 'ClearSessionUseCase',
error: result.error,
});
}
return result;
} catch (error: any) {
this.logger.error('Error clearing user session.', error, {
useCase: 'ClearSessionUseCase'
});
return Result.fail(error.message);
}
}
}
}