Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c09d3723c3 | ||
|
|
5cdbd36999 |
@@ -39,4 +39,4 @@ COPY --from=builder /app/dist ./dist
|
|||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
EXPOSE 3004
|
EXPOSE 3004
|
||||||
ENTRYPOINT ["dumb-init", "--"]
|
ENTRYPOINT ["dumb-init", "--"]
|
||||||
CMD ["sh", "-c", "cd packages/admin-db && npx prisma migrate deploy && cd /app && node dist/main.js"]
|
CMD ["sh", "-c", "cd packages/admin-db && npx prisma migrate deploy && if [ \"$RUN_SEED\" = \"true\" ]; then echo 'Seeding admin database...' && npx tsx prisma/seed.ts; fi && cd /app && node dist/main.js"]
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- CreateTable: support_ticket_attachments
|
||||||
|
CREATE TABLE "support_ticket_attachments" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"ticketId" TEXT NOT NULL,
|
||||||
|
"commentId" TEXT,
|
||||||
|
"fileName" TEXT NOT NULL,
|
||||||
|
"originalName" TEXT NOT NULL,
|
||||||
|
"mimeType" TEXT NOT NULL,
|
||||||
|
"sizeBytes" INTEGER NOT NULL,
|
||||||
|
"uploadedBy" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "support_ticket_attachments_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "support_ticket_attachments_ticketId_idx" ON "support_ticket_attachments"("ticketId");
|
||||||
|
CREATE INDEX "support_ticket_attachments_commentId_idx" ON "support_ticket_attachments"("commentId");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "support_ticket_attachments" ADD CONSTRAINT "support_ticket_attachments_ticketId_fkey"
|
||||||
|
FOREIGN KEY ("ticketId") REFERENCES "support_tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
ALTER TABLE "support_ticket_attachments" ADD CONSTRAINT "support_ticket_attachments_commentId_fkey"
|
||||||
|
FOREIGN KEY ("commentId") REFERENCES "support_ticket_comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
-- Seed the platform superadmin user
|
|
||||||
-- Password: SuperAdmin@123 (bcrypt hash)
|
|
||||||
INSERT INTO "super_admins" ("id", "email", "password", "firstName", "lastName", "isActive", "createdAt", "updatedAt")
|
|
||||||
VALUES (
|
|
||||||
gen_random_uuid(),
|
|
||||||
'superadmin@fiberops.dev',
|
|
||||||
'$2b$12$wiW.foGm.5MD6FNz/HmBvuPaXJS56YPxxq5OEVCO6UXLOxTMvxL8S',
|
|
||||||
'Super',
|
|
||||||
'Admin',
|
|
||||||
true,
|
|
||||||
NOW(),
|
|
||||||
NOW()
|
|
||||||
)
|
|
||||||
ON CONFLICT ("email") DO NOTHING;
|
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import * as bcrypt from 'bcrypt';
|
import * as bcrypt from 'bcrypt';
|
||||||
|
import { randomUUID } from 'crypto';
|
||||||
import { AdminPrismaService } from '../prisma/admin-prisma.service';
|
import { AdminPrismaService } from '../prisma/admin-prisma.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -119,6 +120,7 @@ export class AuthService {
|
|||||||
sub: adminId,
|
sub: adminId,
|
||||||
email,
|
email,
|
||||||
type: 'super_admin',
|
type: 'super_admin',
|
||||||
|
jti: randomUUID(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const refreshSecret = this.config.get<string>(
|
const refreshSecret = this.config.get<string>(
|
||||||
@@ -131,7 +133,7 @@ export class AuthService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const refreshToken = this.jwt.sign(
|
const refreshToken = this.jwt.sign(
|
||||||
{ sub: adminId, email, type: 'super_admin' },
|
{ sub: adminId, email, type: 'super_admin', jti: randomUUID() },
|
||||||
{
|
{
|
||||||
secret: refreshSecret,
|
secret: refreshSecret,
|
||||||
expiresIn: refreshExpiresIn as any,
|
expiresIn: refreshExpiresIn as any,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export class ImpersonateService {
|
|||||||
private readonly audit: AuditService,
|
private readonly audit: AuditService,
|
||||||
) {
|
) {
|
||||||
// Use the MAIN API's JWT secret so the token works with the tenant API
|
// Use the MAIN API's JWT secret so the token works with the tenant API
|
||||||
this.mainJwtSecret = this.config.get<string>('JWT_SECRET', 'dev-jwt-secret-not-for-production');
|
this.mainJwtSecret = this.config.get<string>('MAIN_API_JWT_SECRET', 'your-secret-key');
|
||||||
}
|
}
|
||||||
|
|
||||||
async startImpersonation(tenantId: string, adminId: string, adminName: string) {
|
async startImpersonation(tenantId: string, adminId: string, adminName: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user