Const file for token
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const adminRouter = require('express').Router();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { TOKEN } = require('../const');
|
||||
require('dotenv').config();
|
||||
|
||||
const dataFilePath = path.join(__dirname, '../data.json');
|
||||
@@ -8,7 +9,7 @@ let data = require('../data.json');
|
||||
|
||||
const verifyToken = (req, res, next) => {
|
||||
const token = req.headers['authorization'];
|
||||
if (token === process.env.TOKEN) {
|
||||
if (token === TOKEN) {
|
||||
next();
|
||||
} else {
|
||||
res.status(403).send({ 'status': 'Failed', 'data': 'Invalid token' });
|
||||
|
||||
Reference in New Issue
Block a user