-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ const auth = require('./authHandlers.js'); | |
const sgMail = require('@sendgrid/mail'); | ||
const mongoDB = require("../service/database"); | ||
|
||
var dataHandlers = require('./dataHandlers.js'); | ||
|
||
sgMail.setApiKey(process.env.SENDGRID_API_KEY); | ||
let defaultAddresses = '["[email protected]", "[email protected]", "[email protected]"]'; | ||
let adminAddressRaw = process.env.ADMIN_EMAILS || defaultAddresses; | ||
|
@@ -139,13 +141,19 @@ function editOwnUser(db, collection) { | |
}; | ||
} | ||
|
||
function impersonate(userFunction) { | ||
function impersonate() { | ||
return function(req, res, next) { | ||
let fakeToken = {'email': req.body.email}; | ||
let user = userFunction(fakeToken); | ||
let token = auth.makeJwt(user, auth.PRIKEY, auth.EXPIRY); | ||
req.data = token; | ||
next(); | ||
dataHandlers.User.forLogin(req.body.email).then((x)=>{ | ||
const newToken = {}; | ||
newToken.userType = x[0].userType || 'Null'; | ||
newToken.userFilter = x[0].userFilter || ['Public']; | ||
newToken.sub = req.body.email; | ||
newToken.email = req.body.email; | ||
newToken.name = req.body.email; | ||
newToken.data = x[0]; | ||
req.data = newToken; | ||
next() | ||
Check failure on line 155 in handlers/customHandlers.js GitHub Actions / build (10.x)
|
||
}); | ||
}; | ||
} | ||
|
||
|