delete api/captcha

This commit is contained in:
HF 2022-10-04 14:09:13 +02:00
parent 8991611ce7
commit 9a22be25cc
2 changed files with 0 additions and 62 deletions

View File

@ -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`],
});
}
};

View File

@ -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);