pineafan | c540da9 | 2021-09-03 20:33:36 +0100 | [diff] [blame] | 1 | import Axios from 'axios'; |
| 2 | |
pineafan | aed3024 | 2021-09-04 09:33:40 +0100 | [diff] [blame] | 3 | const Complete = async (req, res) => { |
pineafan | 4580312 | 2022-05-06 21:33:30 +0100 | [diff] [blame] | 4 | let code = await Axios.post('http://127.0.0.1:3000/api/rsmv/validate', {code:req.body.code}); |
pineafan | 9babd75 | 2022-10-21 21:47:52 +0100 | [diff] [blame] | 5 | if (code.status !== 200) { |
pineafan | c540da9 | 2021-09-03 20:33:36 +0100 | [diff] [blame] | 6 | return res.send(404); |
| 7 | } |
pineafan | 9babd75 | 2022-10-21 21:47:52 +0100 | [diff] [blame] | 8 | if (code.data.user !== req.body.uid) return res.send(401) |
| 9 | if (code.data.guild !== req.body.gid) return res.send(401) |
| 10 | if (code.data.role !== req.body.rid) return res.send(401) |
TheCodedProf | 1713ed5 | 2023-03-01 15:53:31 -0500 | [diff] [blame^] | 11 | console.log(req.body) |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 12 | |
pineafan | 4d151ef | 2022-10-28 21:55:56 +0100 | [diff] [blame] | 13 | let secret = process.env.VERIFY_SECRET; |
pineafan | c540da9 | 2021-09-03 20:33:36 +0100 | [diff] [blame] | 14 | let resp = await Axios.get( |
TheCodedProf | 1713ed5 | 2023-03-01 15:53:31 -0500 | [diff] [blame^] | 15 | `http://127.0.0.1:10000/verify/${req.body.gid}/${req.body.rid}/${req.body.uid}/${secret}/${req.body.code}` |
pineafan | 4819ece | 2021-09-04 10:10:29 +0100 | [diff] [blame] | 16 | ) |
pineafan | c540da9 | 2021-09-03 20:33:36 +0100 | [diff] [blame] | 17 | return res.send(resp.status); |
| 18 | } |
pineafan | aed3024 | 2021-09-04 09:33:40 +0100 | [diff] [blame] | 19 | |
| 20 | export default Complete; |