refactor: improve passport strategy handling in async/await manner to prevent race conditions upon importing modules (#682)

This commit is contained in:
Danny Avila 2023-07-22 07:29:17 -07:00 committed by GitHub
parent e38483a8b9
commit 6943f1c2c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 273 additions and 246 deletions

View file

@ -36,8 +36,9 @@ const downloadImage = async (url, imagePath, accessToken) => {
}
};
Issuer.discover(process.env.OPENID_ISSUER)
.then((issuer) => {
async function setupOpenId() {
try {
const issuer = await Issuer.discover(process.env.OPENID_ISSUER);
const client = new issuer.Client({
client_id: process.env.OPENID_CLIENT_ID,
client_secret: process.env.OPENID_CLIENT_SECRET,
@ -128,7 +129,9 @@ Issuer.discover(process.env.OPENID_ISSUER)
);
passport.use('openid', openidLogin);
})
.catch((err) => {
} catch (err) {
console.error(err);
});
}
}
module.exports = setupOpenId;