updated use of environment variables to utilize await

This commit is contained in:
Sheen Capadngan
2023-04-27 02:00:16 +08:00
parent 69472514af
commit 2dd1570200
3 changed files with 9 additions and 8 deletions

View File

@@ -50,8 +50,9 @@ export const login1 = async (req: Request, res: Response) => {
let userId = '';
if (providerAuthToken) {
const decodedToken = <jwt.ProviderAuthJwtPayload>(
jwt.verify(providerAuthToken, getJwtProviderAuthSecret())
jwt.verify(providerAuthToken, await getJwtProviderAuthSecret())
);
userId = decodedToken.userId;
}
@@ -118,7 +119,7 @@ export const login2 = async (req: Request, res: Response) => {
let userId = '';
if (providerAuthToken) {
const decodedToken = <jwt.ProviderAuthJwtPayload>(
jwt.verify(providerAuthToken, getJwtProviderAuthSecret())
jwt.verify(providerAuthToken, await getJwtProviderAuthSecret())
);
userId = decodedToken.userId;
}
@@ -166,8 +167,8 @@ export const login2 = async (req: Request, res: Response) => {
payload: {
userId: user._id.toString()
},
expiresIn: getJwtMfaLifetime(),
secret: getJwtMfaSecret()
expiresIn: await getJwtMfaLifetime(),
secret: await getJwtMfaSecret()
});
const code = await TokenService.createToken({
@@ -205,7 +206,7 @@ export const login2 = async (req: Request, res: Response) => {
httpOnly: true,
path: '/',
sameSite: 'strict',
secure: getHttpsEnabled()
secure: await getHttpsEnabled()
});
// case: user does not have MFA enablgged

View File

@@ -107,7 +107,7 @@ const main = async () => {
app.use(requestIp.mw());
app.use(session({
secret: getSessionSecret(),
secret: await getSessionSecret(),
resave: false, // don't save session if unmodified
saveUninitialized: false, // don't create session until something stored
}));

View File

@@ -38,8 +38,8 @@ passport.use(new GoogleStrategy({
userId: user._id.toString(),
email: user.email,
},
expiresIn: getJwtProviderAuthLifetime(),
secret: getJwtProviderAuthSecret(),
expiresIn: await getJwtProviderAuthLifetime(),
secret: await getJwtProviderAuthSecret(),
});
req.providerAuthToken = providerAuthToken;