From 3e0e807c13a6561cc19f1f8d59f14e6ed7806af8 Mon Sep 17 00:00:00 2001 From: arttu Date: Sat, 29 Jun 2024 00:00:34 +0300 Subject: [PATCH] debug logs 2 --- server/middleware/authenticationMiddleware.js | 5 +++-- server/util/common.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/middleware/authenticationMiddleware.js b/server/middleware/authenticationMiddleware.js index f0d703b..289d3be 100644 --- a/server/middleware/authenticationMiddleware.js +++ b/server/middleware/authenticationMiddleware.js @@ -1,7 +1,7 @@ -const { inProduction, isSuperAdmin } = require('../util/common') const Sentry = require('@sentry/node') const logger = require('@util/logger') const { StudyProgram, User, ServiceStatus } = require('@models') +const { inProduction, isSuperAdmin } = require('../util/common') const authentication = async (req, res, next) => { // Headers are in by default lower case, we don't like that. @@ -18,6 +18,7 @@ const authentication = async (req, res, next) => { if (!uid) return res.status(403).json({ error: 'forbidden' }) const superAdmin = isSuperAdmin(uid) + console.log(`User ${uid}, superAdmin=${superAdmin}`) const loggedInAs = req.headers['x-admin-logged-in-as'] if (loggedInAs) { if (superAdmin) { @@ -30,7 +31,7 @@ const authentication = async (req, res, next) => { } req.canary = hygroupcn && hygroupcn.includes('grp-toska') - + console.log(`canary: ${req.canary}`) const foundUser = await User.findOne({ where: { userId: uid }, include: [ diff --git a/server/util/common.js b/server/util/common.js index 77d76c8..6f1587b 100644 --- a/server/util/common.js +++ b/server/util/common.js @@ -4,6 +4,7 @@ const isSuperAdmin = (userId) => { if (userId === 'admin' && !common.inProduction) return true console.log(`userId: ${userId} superAdmins: ${process.env.SUPERADMINS}`) if (process.env.SUPERADMINS && process.env.SUPERADMINS.split(',').find(u => u === userId)) return true + console.log(`userId: ${userId} not super admin`) return false }