2026-04-15-4

This commit is contained in:
Hamza-Ayed
2026-04-15 19:56:49 +03:00
parent 9cd1ac4c1d
commit 3d61362602
54 changed files with 12659 additions and 436 deletions
+18 -13
View File
@@ -1,25 +1,23 @@
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { Controller, Get, Post, Body, Param, UseGuards, Req } from '@nestjs/common';
import { AuthService } from './auth.service';
import { CreateKeyDto } from './dto/management/create-key.dto';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { FirebaseAuthGuard } from './guards/firebase-auth.guard';
@ApiTags('auth')
@ApiBearerAuth()
@UseGuards(FirebaseAuthGuard)
@Controller('auth/management')
export class TenantController {
constructor(private readonly authService: AuthService) {}
@Get('keys/:tenantId')
@ApiOperation({ summary: 'Get all API keys for a tenant' })
async getKeys(@Param('tenantId') tenantId: string) {
return this.authService.getApiKeys(tenantId);
}
@Post('keys/:tenantId')
@Post('keys')
@ApiOperation({ summary: 'Create a new API key' })
async createKey(
@Param('tenantId') tenantId: string,
@Req() req: any,
@Body() dto: CreateKeyDto
) {
const tenantId = req.tenant.id;
return this.authService.createApiKey(
tenantId,
dto.name,
@@ -28,9 +26,16 @@ export class TenantController {
);
}
@Get('keys')
@ApiOperation({ summary: 'Get all API keys for the authenticated tenant' })
async getKeys(@Req() req: any) {
const tenantId = req.tenant.id;
return this.authService.getApiKeys(tenantId);
}
@Get('me')
@ApiOperation({ summary: 'Identify the default tenant (Demo Only)' })
async getMe() {
return this.authService.getDefaultTenant();
@ApiOperation({ summary: 'Get current authenticated tenant info' })
async getMe(@Req() req: any) {
return req.tenant;
}
}