import { Body, Controller, Delete, Param, Post, Put } from '@nestjs/common';
import { ExcludePrivilege, Public } from 'src/core/guards';
import { ApiBearerAuth } from '@nestjs/swagger';
import { ForceLogoutDto, LoginQueueDto } from './dto/login.dto';
import { AuthAdminQueueOrchestrator } from '../domain/auth-admin-queue.orchestrator';

@Controller('v1/auth/queue')
export class AuthAdminQueueController {
  constructor(private orchestrator: AuthAdminQueueOrchestrator) {}

  @Post()
  @Public(true)
  async login(@Body() body: LoginQueueDto) {
    return await this.orchestrator.login(body);
  }

  @ApiBearerAuth('JWT')
  @Public(false)
  @ExcludePrivilege()
  @Delete('logout')
  async logout() {
    return await this.orchestrator.logout();
  }

  @Put(':user_id/logout')
  async logoutQueueAdmin(@Param('user_id') userId: string) {
    return await this.orchestrator.logout(userId);
  }

  @Post('force-logout')
  @Public(true)
  async forceLogout(@Body() body: ForceLogoutDto) {
    return await this.orchestrator.forceLogout(body.token);
  }
}
