From b61bf4876cf0461411916012c2bcbcab14d4703b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Tue, 19 Mar 2024 01:12:20 +0300 Subject: [PATCH] access tokens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferit Yiğit BALABAN --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7912da4..899211b 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,12 @@ const mailRouteLimiter = rateLimit({ }); app.post('/api/mail', mailRouteLimiter, (req, res) => { - const { to, subject, text } = req.body; + const { to, subject, text, access } = req.body; + + if (!process.env.ACCESS_KEYS.split(',').includes(access)) { + return res.status(403).json({ success: false, message: 'Access denied!' }); + console.log('Access denied!'); + } const mail = { from: `"Arbeit Mail Hizmeti" <${SENDER_EMAIL}>`,