Skip to content

Commit

Permalink
debug logs 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ShootingStar91 committed Jun 28, 2024
1 parent 4dd3427 commit 3e0e807
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/middleware/authenticationMiddleware.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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) {
Expand All @@ -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: [
Expand Down
1 change: 1 addition & 0 deletions server/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3e0e807

Please sign in to comment.