blob: 9b2ea9e488cbb7450cf5d8bc28583fba4099f4ac [file] [log] [blame]
pineafanc540da92021-09-03 20:33:36 +01001import Axios from 'axios';
2
pineafanaed30242021-09-04 09:33:40 +01003const Complete = async (req, res) => {
pineafan45803122022-05-06 21:33:30 +01004 let code = await Axios.post('http://127.0.0.1:3000/api/rsmv/validate', {code:req.body.code});
pineafan9babd752022-10-21 21:47:52 +01005 if (code.status !== 200) {
pineafanc540da92021-09-03 20:33:36 +01006 return res.send(404);
7 }
pineafan9babd752022-10-21 21:47:52 +01008 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)
pineafanf97734b2021-11-23 21:11:00 +000011
pineafan4d151ef2022-10-28 21:55:56 +010012 let secret = process.env.VERIFY_SECRET;
pineafanc540da92021-09-03 20:33:36 +010013 let resp = await Axios.get(
pineafan45803122022-05-06 21:33:30 +010014 `http://localhost:10000/verify/${req.body.gid}/${req.body.rid}/${req.body.uid}/${secret}/${req.body.code}`
pineafan4819ece2021-09-04 10:10:29 +010015 )
pineafanc540da92021-09-03 20:33:36 +010016 return res.send(resp.status);
17}
pineafanaed30242021-09-04 09:33:40 +010018
19export default Complete;