29 lines
644 B
TypeScript
29 lines
644 B
TypeScript
import { Request, Response, NextFunction } from "express";
|
|
import dotenv from "dotenv";
|
|
import { resolve } from "path";
|
|
import { logger } from "../server";
|
|
|
|
dotenv.config({
|
|
path: resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`),
|
|
});
|
|
|
|
export default function ValidateImsToken(
|
|
req: Request,
|
|
res: Response,
|
|
next: NextFunction
|
|
) {
|
|
const jobid: string = (req.body.jobid || "").trim();
|
|
|
|
const IMS_TOKEN: string = (process.env.IMS_TOKEN || "").trim();
|
|
|
|
if (IMS_TOKEN === "") {
|
|
next();
|
|
} else {
|
|
if (req.headers.ims_token !== IMS_TOKEN) {
|
|
res.sendStatus(401);
|
|
} else {
|
|
next();
|
|
}
|
|
}
|
|
}
|