21 lines
906 B
TypeScript
21 lines
906 B
TypeScript
import type { AuthCallbackCommandDTO } from '../dto/AuthCallbackCommandDTO';
|
|
import type { AuthSessionDTO } from '../dto/AuthSessionDTO';
|
|
import type { AuthenticatedUserDTO } from '../dto/AuthenticatedUserDTO';
|
|
import type { IdentityProviderPort } from '../ports/IdentityProviderPort';
|
|
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
|
|
|
export class HandleAuthCallbackUseCase {
|
|
private readonly provider: IdentityProviderPort;
|
|
private readonly sessionPort: IdentitySessionPort;
|
|
|
|
constructor(provider: IdentityProviderPort, sessionPort: IdentitySessionPort) {
|
|
this.provider = provider;
|
|
this.sessionPort = sessionPort;
|
|
}
|
|
|
|
async execute(command: AuthCallbackCommandDTO): Promise<AuthSessionDTO> {
|
|
const user: AuthenticatedUserDTO = await this.provider.completeAuth(command);
|
|
const session = await this.sessionPort.createSession(user);
|
|
return session;
|
|
}
|
|
} |