fix(app): required auth was in wrong spot caused entire app to want you logged in
This commit is contained in:
@@ -43,7 +43,7 @@ const parseZebraAlert = (body: any): PrinterEvent => {
|
||||
};
|
||||
};
|
||||
|
||||
r.post("/printer/listener/:printer", upload.any(), async (req, res) => {
|
||||
r.post("/:printer", upload.any(), async (req, res) => {
|
||||
const { printer: printerName } = req.params;
|
||||
const event: PrinterEvent = parseZebraAlert(req.body);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import { printerSync } from "./ocp.printer.manage.js";
|
||||
|
||||
const r = Router();
|
||||
|
||||
r.post("/printer/update", async (_, res) => {
|
||||
r.post("/update", async (_, res) => {
|
||||
printerSync();
|
||||
return apiReturn(res, {
|
||||
success: true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Express, Router } from "express";
|
||||
import type { Express } from "express";
|
||||
import { requireAuth } from "../middleware/auth.middleware.js";
|
||||
import { featureCheck } from "../middleware/featureActive.middleware.js";
|
||||
|
||||
@@ -6,20 +6,11 @@ import listener from "./ocp.printer.listener.js";
|
||||
import update from "./ocp.printer.update.js";
|
||||
|
||||
export const setupOCPRoutes = (baseUrl: string, app: Express) => {
|
||||
//setup all the routes
|
||||
const router = Router();
|
||||
|
||||
// is the feature even on?
|
||||
router.use(featureCheck("ocp"));
|
||||
|
||||
// non auth routes up here
|
||||
router.use(listener);
|
||||
|
||||
// auth routes below here
|
||||
router.use(requireAuth);
|
||||
|
||||
router.use(update);
|
||||
//router.use("");
|
||||
|
||||
app.use(`${baseUrl}/api/ocp`, router);
|
||||
app.use(`${baseUrl}/api/ocp/printer/listener`, featureCheck("ocp"), listener);
|
||||
app.use(
|
||||
`${baseUrl}/api/ocp/printer`,
|
||||
featureCheck("ocp"),
|
||||
requireAuth,
|
||||
update,
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user