fix: use JWT tenantId instead of header in FIEL and SAT controllers

The controllers were looking for x-tenant-id header which the frontend
doesn't send. Now using req.user!.tenantId from the JWT token instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Consultoria AS
2026-01-25 01:45:42 +00:00
parent 2dd22ec152
commit 75a9819c1e
2 changed files with 7 additions and 47 deletions

View File

@@ -7,11 +7,7 @@ import type { FielUploadRequest } from '@horux/shared';
*/
export async function upload(req: Request, res: Response): Promise<void> {
try {
const tenantId = req.headers['x-tenant-id'] as string;
if (!tenantId) {
res.status(400).json({ error: 'Tenant ID requerido' });
return;
}
const tenantId = req.user!.tenantId;
const { cerFile, keyFile, password } = req.body as FielUploadRequest;
@@ -42,12 +38,7 @@ export async function upload(req: Request, res: Response): Promise<void> {
*/
export async function status(req: Request, res: Response): Promise<void> {
try {
const tenantId = req.headers['x-tenant-id'] as string;
if (!tenantId) {
res.status(400).json({ error: 'Tenant ID requerido' });
return;
}
const tenantId = req.user!.tenantId;
const fielStatus = await getFielStatus(tenantId);
res.json(fielStatus);
} catch (error: any) {
@@ -61,12 +52,7 @@ export async function status(req: Request, res: Response): Promise<void> {
*/
export async function remove(req: Request, res: Response): Promise<void> {
try {
const tenantId = req.headers['x-tenant-id'] as string;
if (!tenantId) {
res.status(400).json({ error: 'Tenant ID requerido' });
return;
}
const tenantId = req.user!.tenantId;
const deleted = await deleteFiel(tenantId);
if (!deleted) {