Skip to content

Commit 7204a18

Browse files
committed
Added key
1 parent 55bddaa commit 7204a18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/controllers/v4/internal/stats.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const getMonthlyRequests = async (req, res, next) => {
8585

8686
// Check for valid access key in headers
8787
if (!key || key !== process.env.ACCESS_KEY) {
88-
// return res.status(401).json({ message: 'Unauthorized' });
88+
return res.status(401).json({ message: 'Unauthorized' });
8989
}
9090

9191
for (let i = 4; i >= 0; i--) {
@@ -126,6 +126,11 @@ const getUsersStat = async (req, res, next) => {
126126
try {
127127
const { type, top } = req.query;
128128
const [start, end] = parseTopParam(top);
129+
const key = req.headers.key;
130+
131+
if (!key || key !== process.env.ACCESS_KEY) {
132+
return res.status(401).json({ message: 'Unauthorized' });
133+
}
129134

130135
// ✅ Validate Type
131136
if (!['quota', 'requests'].includes(type)) {

0 commit comments

Comments
 (0)