This commit is contained in:
louiscklaw
2025-01-31 19:15:17 +08:00
parent 09adae8c8e
commit 6c60a73f30
1546 changed files with 286918 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import express from 'express';
export const isLoggedIn = (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (req.session?.user) {
next();
} else {
res.status(404).redirect('/landingPage.html');
}
};
export const isLoggedInAPI = (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (req.session?.user) {
next();
} else {
// redirect to 404 page
res.status(400).json({ error: "You don't have the permission" });
}
};
export const isLoggedInInvitation = (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (req.session?.user) {
next();
} else {
res.json({
status: false,
login: false
});
}
};