Skip to content

Commit

Permalink
Merge pull request #11 from icefoganalytics/main
Browse files Browse the repository at this point in the history
Refix
  • Loading branch information
datajohnson authored Aug 1, 2024
2 parents 2a60acf + 523d834 commit 776025e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 16 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ COPY --from=web-build-stage --chown=node:node /usr/src/web/dist ./dist/web/
RUN echo "RELEASE_TAG=${RELEASE_TAG}" >> VERSION
RUN echo "GIT_COMMIT_HASH=${GIT_COMMIT_HASH}" >> VERSION

ENV NODE_TLS_REJECT_UNAUTHORIZED=0
ENV NODE_OPTIONS=--openssl-legacy-provider

EXPOSE 3000

CMD ["node", "./dist/index.js"]
2 changes: 1 addition & 1 deletion api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ app.use("/migrate", migrator.migrationRouter);
app.use("/api/documents", documentsRouter);
app.use("/api/department", checkJwt, loadUser, departmentRouter);
app.use("/api/documentation", checkJwt, loadUser, documentationRouter);
app.use("/api/user", checkJwt, userRouter);
app.use("/api/user", checkJwt, loadUser, userRouter);

// serves the static files generated by the front-end
app.use(express.static(path.join(__dirname, "web")));
Expand Down
12 changes: 0 additions & 12 deletions api/src/middleware/authz.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,16 @@ export const checkJwt = jwt({
});

export async function loadUser(req: Request, res: Response, next: NextFunction) {
console.log("H0")

const db = new UserService();

console.log("H1")

let sub = req.auth.sub;
const token = req.headers.authorization || "";
let u = await db.getBySub(sub);


console.log("H2")

if (u) {
req.user = { ...req.auth, ...u };
return next();
}
console.log("H3",`${AUTH0_DOMAIN}/userinfo`)

await axios
.get(`${AUTH0_DOMAIN}/userinfo`, { headers: { authorization: token } })
.then(async (resp: any) => {
Expand All @@ -52,15 +43,12 @@ export async function loadUser(req: Request, res: Response, next: NextFunction)

let u = await db.getBySub(sub);

console.log("SUB", sub, u);

if (u) {
req.user = { ...req.auth, ...u };
} else {
if (!email) email = `${first_name}.${last_name}@yukon-no-email.ca`;

let e = await db.getByEmail(email);
console.log("EMAIL", email, e);

if (e && e.auth_subject == "SUB_MISSING") {
req.user = { ...req.auth, ...e };
Expand Down

0 comments on commit 776025e

Please sign in to comment.