From 9a22be25ccc5e8fe7885227c3df573db64a99719 Mon Sep 17 00:00:00 2001 From: HF Date: Tue, 4 Oct 2022 14:09:13 +0200 Subject: [PATCH] delete api/captcha --- src/routes/api/captcha.js | 60 --------------------------------------- src/routes/api/index.js | 2 -- 2 files changed, 62 deletions(-) delete mode 100644 src/routes/api/captcha.js diff --git a/src/routes/api/captcha.js b/src/routes/api/captcha.js deleted file mode 100644 index 00a34aff..00000000 --- a/src/routes/api/captcha.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This is just for verifying captcha tokens, - * the actual notification that a captcha is needed is sent - * with the pixel return answer when sending apixel on websocket - * - */ - -import logger from '../../core/logger'; -import { checkCaptchaSolution } from '../../data/redis/captcha'; -import { getIPFromRequest } from '../../utils/ip'; - -export default async (req, res) => { - const ip = getIPFromRequest(req); - const { t } = req.ttag; - - try { - const { text, id } = req.body; - - const ret = await checkCaptchaSolution( - text, - ip, - false, - id, - ); - - switch (ret) { - case 0: - res.status(200) - .json({ success: true }); - break; - case 1: - res.status(422) - .json({ - errors: [t`You took too long, try again.`], - }); - break; - case 2: - res.status(422) - .json({ errors: [t`You failed your captcha`] }); - break; - case 3: - res.status(400) - .json({ errors: [t`No captcha text given`] }); - break; - case 4: - res.status(400) - .json({ errors: [t`No captcha id given`] }); - break; - default: - res.status(422) - .json({ errors: [t`Unknown Captcha Error`] }); - } - } catch (error) { - logger.error('CAPTCHA', error); - res.status(500) - .json({ - errors: [t`Server error occured`], - }); - } -}; diff --git a/src/routes/api/index.js b/src/routes/api/index.js index 26765cf9..faf9f5d6 100644 --- a/src/routes/api/index.js +++ b/src/routes/api/index.js @@ -7,7 +7,6 @@ import User from '../../data/User'; import { getIPFromRequest } from '../../utils/ip'; import me from './me'; -import captcha from './captcha'; import auth from './auth'; import chatHistory from './chathistory'; import startDm from './startdm'; @@ -43,7 +42,6 @@ router.use((err, req, res, next) => { }); // routes that don't need a user -router.post('/captcha', captcha); router.get('/baninfo', baninfo); router.get('/getiid', getiid); router.get('/shards', shards);