[FIX] Use New Cairo System
Some checks failed
Deploy USW-MC / deploy-edge (push) Failing after 2s
Deploy Edge Proxy / deploy-edge (push) Failing after 2s
S3 Repo Backup / s3-repo-backup (push) Failing after 5s

This commit is contained in:
Dunemask 2024-08-24 16:41:52 -06:00
parent 6eed3fd694
commit 8c7e41b21b
4 changed files with 12 additions and 9 deletions

View file

@ -4,12 +4,12 @@ import bearerTokenMiddleware from "express-bearer-token";
import { ERR, VERB } from "../../util/logging.js";
// Constants
const { MCL_CAIRO_URL } = process.env;
const { MCL_CAIRO_URL, MCL_CAIRO_PROJECT } = process.env;
const cairoAuthMiddleware = Router();
const cairoAuthenticate = async (token) => {
const config = { headers: { Authorization: `Bearer ${token}` } };
return fetch(`${MCL_CAIRO_URL}/api/user/info`, config).then(async (res) => {
return fetch(`${MCL_CAIRO_URL}/api/${MCL_CAIRO_PROJECT}/auth/credentials`, config).then(async (res) => {
if (res.status >= 300) {
const errorMessage = await res
.json()
@ -30,9 +30,9 @@ const cairoAuthHandler = (req, res, next) => {
cairoAuthenticate(req.token)
.then((authData) => {
console.log(authData);
if (!authData.id)
throw Error(`Cairo didn't return the expected data! ${authData.id}`);
req.cairoId = authData.id;
if (!authData?.user?.id)
throw Error(`Cairo didn't return the expected data! ${authData?.user?.id}`);
req.cairoId = authData?.user?.id;
})
.then(() => next())
.catch((err) => {