feat: verifyStatusPage middleware
This commit is contained in:
1 parent
dae2709d31
commit
b87fd5438e
1 file changed
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import { IStatusPagesRepository } from "@/repositories/index.js";
|
||||||
|
|
||||||
|
export const createVerifyStatusPageAccess = (statusPagesRepository: IStatusPagesRepository) => {
|
||||||
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
const url = req.params.url;
|
||||||
|
const statusPage = await statusPagesRepository.findByUrl(url);
|
||||||
|
if (statusPage.isPublished) {
|
||||||
|
next(); // Published — proceed to controller (no JWT)
|
||||||
|
} else {
|
||||||
|
next("route"); // Unpublished — skip to next route (which has verifyJWT)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in new issue
Block a user