delete api/captcha
This commit is contained in:
parent
8991611ce7
commit
9a22be25cc
|
@ -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`],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -7,7 +7,6 @@ import User from '../../data/User';
|
||||||
import { getIPFromRequest } from '../../utils/ip';
|
import { getIPFromRequest } from '../../utils/ip';
|
||||||
|
|
||||||
import me from './me';
|
import me from './me';
|
||||||
import captcha from './captcha';
|
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
import chatHistory from './chathistory';
|
import chatHistory from './chathistory';
|
||||||
import startDm from './startdm';
|
import startDm from './startdm';
|
||||||
|
@ -43,7 +42,6 @@ router.use((err, req, res, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// routes that don't need a user
|
// routes that don't need a user
|
||||||
router.post('/captcha', captcha);
|
|
||||||
router.get('/baninfo', baninfo);
|
router.get('/baninfo', baninfo);
|
||||||
router.get('/getiid', getiid);
|
router.get('/getiid', getiid);
|
||||||
router.get('/shards', shards);
|
router.get('/shards', shards);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user