1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-19 13:19:42 +02:00

Implement yaml config (#271)

This commit is contained in:
Nikita Melnikov 2022-09-29 06:41:24 +08:00 committed by GitHub
parent 5a7f1c843b
commit 13762096c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 164 additions and 479 deletions

View file

@ -1,6 +1,6 @@
import config from 'config';
import { NextFunction, Request, Response } from 'express';
import jwt from 'jsonwebtoken';
import appConfig from "../../utils/appConfig.js";
/**
@ -14,14 +14,14 @@ export default async function verifyToken(req: Request, res: Response, next: Nex
const token = req.cookies.authToken;
try {
if (!process.env.PASSWORD) {
if (!appConfig.password) {
res.locals.isAuthorized = false;
next();
return;
}
const decodedToken = jwt.verify(token, process.env.PASSWORD + config.get('secret'));
const decodedToken = jwt.verify(token, appConfig.password + appConfig.auth.secret);
res.locals.isAuthorized = !!decodedToken;