First commit

This commit is contained in:
AndrewTrieu
2023-04-21 13:17:50 +03:00
commit c9f31e5c8a
26 changed files with 465 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
const restrictedPaths = ["/index"];
const authMiddleware = async (context, next) => {
const user = await context.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 };