Oops, fix bug on boot caused by login changes
I forgot that we sometimes use the Apollo server in a context where `req` and `res` aren't present! (namely in our `build-cached-data` script.) In this change, we update the DTI-Auth-Mode HTTP header check to be cognizant that the request might be absent!
This commit is contained in:
parent
f7f6f7b82b
commit
5bf037b193
1 changed files with 2 additions and 2 deletions
|
@ -67,10 +67,10 @@ const config = {
|
|||
context: async ({ req, res }) => {
|
||||
const db = await connectToDb();
|
||||
|
||||
let authMode = req.headers["dti-auth-mode"] || "auth0";
|
||||
let authMode = req?.headers?.["dti-auth-mode"] || "auth0";
|
||||
let currentUserId;
|
||||
if (authMode === "auth0") {
|
||||
const auth = (req && req.headers && req.headers.authorization) || "";
|
||||
const auth = req?.headers?.authorization || "";
|
||||
const authMatch = auth.match(/^Bearer (.+)$/);
|
||||
const token = authMatch && authMatch[1];
|
||||
currentUserId = await getUserIdFromTokenViaAuth0(token);
|
||||
|
|
Loading…
Reference in a new issue