import type { BackofficeSessionRepository } from '../domain/ports.js';

export class BackofficeLogout {
  constructor(
    private readonly sessions: BackofficeSessionRepository,
    private readonly hashToken: (token: string) => string,
  ) {}

  async execute(rawToken: string | undefined): Promise<void> {
    if (!rawToken) return;
    await this.sessions.revokeByTokenHash(this.hashToken(rawToken));
  }
}
