Fix context

This commit is contained in:
AndrewTrieu
2023-03-10 16:52:00 +02:00
parent 0fab2411ee
commit ee0936c8b1
5 changed files with 6 additions and 714 deletions

View File

@@ -1,7 +1,7 @@
const restrictedPaths = ["/quiz", "/topics"];
const restrictedPaths = ["/topics", "/quiz"];
const authMiddleware = async (state, next) => {
const user = await state.session.get("user");
const authMiddleware = async (context, next) => {
const user = await context.state.session?.get("user");
if (
!user &&

View File

@@ -1,4 +1,4 @@
const errorMiddleware = async (next) => {
const errorMiddleware = async (context, next) => {
try {
await next();
} catch (e) {

View File

@@ -1,7 +1,7 @@
import * as authService from "../services/authService.js";
const userMiddleware = async (context, next) => {
const user = await context.state.session.get("user");
const user = await context.state.session?.get("user");
if (user) {
const userFromDatabase = await authService.findUser(user.email);