WIP - improve login to tenants by domains
This commit is contained in:
@@ -15,6 +15,7 @@ import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { CentralTenant, CentralDomain, CentralUser } from '../models/central.model';
|
||||
import { getCentralKnex, initCentralModels } from './central-database.service';
|
||||
import { TenantProvisioningService } from './tenant-provisioning.service';
|
||||
import { TenantDatabaseService } from './tenant-database.service';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
|
||||
/**
|
||||
@@ -26,6 +27,7 @@ import * as bcrypt from 'bcrypt';
|
||||
export class CentralAdminController {
|
||||
constructor(
|
||||
private readonly provisioningService: TenantProvisioningService,
|
||||
private readonly tenantDbService: TenantDatabaseService,
|
||||
) {
|
||||
// Initialize central models on controller creation
|
||||
initCentralModels();
|
||||
@@ -173,7 +175,18 @@ export class CentralAdminController {
|
||||
@Delete('domains/:id')
|
||||
async deleteDomain(@Req() req: any, @Param('id') id: string) {
|
||||
this.checkCentralAdmin(req);
|
||||
|
||||
// Get domain info before deleting to invalidate cache
|
||||
const domain = await CentralDomain.query().findById(id);
|
||||
|
||||
// Delete the domain
|
||||
await CentralDomain.query().deleteById(id);
|
||||
|
||||
// Invalidate tenant connection cache for this domain
|
||||
if (domain) {
|
||||
this.tenantDbService.removeTenantConnection(domain.domain);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user