Major bug fix

This commit is contained in:
AndrewTrieu
2023-03-10 16:41:57 +02:00
parent 4c8e7e8588
commit 0fab2411ee
19 changed files with 965 additions and 19 deletions

View File

@@ -0,0 +1,18 @@
const restrictedPaths = ["/quiz", "/topics"];
const authMiddleware = async (state, next) => {
const user = await state.session.get("user");
if (
!user &&
restrictedPaths.some((path) =>
context.request.url.pathname.startsWith(path)
)
) {
context.response.redirect("/auth/login");
} else {
await next();
}
};
export { authMiddleware };