pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 1 | import Axios from 'axios'; |
| 2 | import qs from 'querystring'; |
| 3 | |
| 4 | const Complete = async (req, res) => { |
pineafan | aa9c4fd | 2022-06-10 19:58:10 +0100 | [diff] [blame] | 5 | const chk = await Axios.post('https://hcaptcha.com/siteverify', qs.stringify({ |
| 6 | response: req.body.tkn, |
| 7 | secret: '0x19C699BFfce07b2a026121DE6702706BB2d51D6c', |
| 8 | sitekey: '85074411-fa13-4d9b-b901-53095c6d1fc6' |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 9 | })) |
| 10 | if ( !chk.data.success ) { |
| 11 | return res.status(200).send({success: false}) |
| 12 | } |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 13 | try { |
TheCodedProf | f054b8c | 2023-03-03 15:32:19 -0500 | [diff] [blame^] | 14 | await Axios.post(`${process.env.NUCLEUS_CALLBACK}/verify/${req.body.code}`, { |
pineafan | 83152e2 | 2022-06-13 17:52:55 +0100 | [diff] [blame] | 15 | secret: process.env.VERIFY_SECRET |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 16 | }); |
| 17 | } catch (e) { |
| 18 | return res.status(200).send({success: false}) |
| 19 | } |
| 20 | return res.status(200).send({success: true}); |
| 21 | } |
| 22 | |
| 23 | export default Complete; |