oops, fix build errors from using future syntax

worked in some local contexts, but the prod build failed!
This commit is contained in:
Emi Matchu 2020-09-02 23:07:44 -07:00
parent 12b87ee7d1
commit ba004ae656
2 changed files with 8 additions and 4 deletions

View file

@ -1313,12 +1313,12 @@ async function getUserIdFromToken(token) {
return null;
}
const userId = payload.sub.match(/auth0\|impress-([0-9]+)/)?.[1];
if (!userId) {
const subMatch = payload.sub.match(/auth0\|impress-([0-9]+)/);
if (!subMatch) {
console.log("Unexpected auth token sub format", payload.sub);
return null;
}
const userId = subMatch[1];
return userId;
}
@ -1335,7 +1335,8 @@ const config = {
};
lastSvgLogger = svgLogger;
const token = req.headers.authorization?.match(/^Bearer (.+)$/)?.[1];
const tokenMatch = (req.headers.authorization || "").match(/^Bearer (.+)$/);
const token = tokenMatch && tokenMatch[1];
const currentUserId = await getUserIdFromToken(token);
return {

View file

@ -3,6 +3,9 @@ const { query, getDbCalls, logInAsTestUser } = require("./setup.js");
describe("User", () => {
it("looks up a user", async () => {
// TODO: I'm not sure why this is taking extra time, maybe the db conn?
jest.setTimeout(10000);
const res = await query({
query: gql`
query {