aboutsummaryrefslogtreecommitdiffstats
path: root/lib/passport.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/passport.js')
-rw-r--r--lib/passport.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/passport.js b/lib/passport.js
index 7cf07962..68adbe08 100644
--- a/lib/passport.js
+++ b/lib/passport.js
@@ -1,4 +1,5 @@
import app from "$app";
+import db from "$db";
import Passport from "passport";
import jwt from "passport-jwt";
import { Op } from "@sequelize/core";
@@ -7,6 +8,7 @@ import fastifySecureSession from '@fastify/secure-session'
import config from "$config";
import fs from "fs";
import path from "path";
+import { err } from "$lib/logging";
app.register(fastifySecureSession, {
key: config.jwt
@@ -58,9 +60,8 @@ export const optionalAuth = {
preValidation: fastifyPassport.authenticate(
"jwt",
{ session: false },
- function(err, user, info) {
+ function(req, res, err, user, info) {
req.user = user;
- next();
}
)
};
@@ -69,10 +70,9 @@ export const adminAuth = {
preValidation: fastifyPassport.authenticate(
"jwt",
{ session: false },
- function(err, user, info) {
+ function(req, res, err, user, info) {
if (!(user && user.admin)) return res.status(401).send("Unauthorized");
req.user = user;
- next();
}
)
};