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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user