fix: validate request org id existance in guards

This commit is contained in:
Ahmed Bouhuolia
2025-10-25 15:15:13 +02:00
parent 2b4772a070
commit 1bccba572a
3 changed files with 23 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ export class EnsureTenantIsSeededGuard implements CanActivate {
constructor(
private readonly tenancyContext: TenancyContext,
private reflector: Reflector,
) {}
) { }
/**
* Validate the tenant of the current request is seeded.
@@ -41,6 +41,12 @@ export class EnsureTenantIsSeededGuard implements CanActivate {
}
const tenant = await this.tenancyContext.getTenant();
if (!tenant) {
throw new UnauthorizedException({
message: 'Tenant not found.',
errors: [{ type: 'TENANT.NOT.FOUND' }],
});
}
if (!tenant.seededAt) {
throw new UnauthorizedException({
message: 'Tenant database is not seeded with initial data yet.',