Fix context
This commit is contained in:
@@ -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 &&
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const errorMiddleware = async (next) => {
|
||||
const errorMiddleware = async (context, next) => {
|
||||
try {
|
||||
await next();
|
||||
} catch (e) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user