mirror of
https://github.com/Mestima/GM-Discord.git
synced 2025-05-05 22:00:14 +00:00
node webpart request security fix
This commit is contained in:
parent
06580802e1
commit
52d332450b
@ -3,5 +3,6 @@
|
||||
"token": "",
|
||||
"channel": "",
|
||||
"webhook": "",
|
||||
"security": true,
|
||||
"debug": false
|
||||
}
|
12
web/nodejs/dist/index.js
vendored
12
web/nodejs/dist/index.js
vendored
@ -12,6 +12,7 @@ const port = config.port;
|
||||
const webhook = config.webhook;
|
||||
const channel = config.channel;
|
||||
const token = config.token;
|
||||
const security = config.security;
|
||||
const debug = config.debug;
|
||||
app.post("/send", (req, res) => {
|
||||
const content = req.query.content;
|
||||
@ -42,6 +43,17 @@ app.post("/send", (req, res) => {
|
||||
});
|
||||
});
|
||||
app.get("/request", (req, res) => {
|
||||
if (security) {
|
||||
const postToken = req.query.token;
|
||||
const postChannel = req.query.channel;
|
||||
if (channel != postChannel || token != postToken) {
|
||||
const err = `error: unknown token or channel`;
|
||||
if (debug) {
|
||||
console.log(err);
|
||||
}
|
||||
return res.send(err);
|
||||
}
|
||||
}
|
||||
node_fetch_1.default(`https://discordapp.com/api/channels/${channel}/messages?token=Bot ${token}`)
|
||||
.then(discordRes => discordRes.json())
|
||||
.then(json => {
|
||||
|
@ -10,6 +10,8 @@ const port = config.port;
|
||||
const webhook = config.webhook;
|
||||
const channel = config.channel;
|
||||
const token = config.token;
|
||||
|
||||
const security = config.security;
|
||||
const debug = config.debug;
|
||||
|
||||
app.post("/send", (req, res) => {
|
||||
@ -45,6 +47,18 @@ app.post("/send", (req, res) => {
|
||||
});
|
||||
|
||||
app.get("/request", (req, res) => {
|
||||
if (security) {
|
||||
const postToken: any = req.query.token;
|
||||
const postChannel: any = req.query.channel;
|
||||
if (channel != postChannel || token != postToken) {
|
||||
const err = `error: unknown token or channel`;
|
||||
if (debug) {
|
||||
console.log(err);
|
||||
}
|
||||
return res.send(err);
|
||||
}
|
||||
}
|
||||
|
||||
fetch(`https://discordapp.com/api/channels/${channel}/messages?token=Bot ${token}`)
|
||||
.then(discordRes => discordRes.json())
|
||||
.then(json => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user