Add in permission checking

merge-requests/17/head
Hiroyuki 2021-02-06 00:14:27 -04:00
parent 64b59bdd35
commit d83c35b256
No known key found for this signature in database
GPG Key ID: C15AC26538975A24
1 changed files with 3 additions and 2 deletions

View File

@ -20,8 +20,9 @@ export default class Root extends Route {
} }
const director = await this.server.client.db.Score.findOne({ pin: req.body.pin }); const director = await this.server.client.db.Score.findOne({ pin: req.body.pin });
const staffGuild = this.server.client.guilds.get('446067825673633794') || await this.server.client.getRESTGuild('446067825673633794');
if (!director) { if (!director || !staffGuild.members.get(director.userID)?.roles?.includes('662163685439045632')) {
return res.status(401).json({ return res.status(401).json({
code: this.constants.codes.UNAUTHORIZED, code: this.constants.codes.UNAUTHORIZED,
message: this.constants.messages.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED,
@ -50,8 +51,8 @@ export default class Root extends Route {
oID: genUUID(), oID: genUUID(),
}); });
const staffInformation = await this.server.client.db.Staff.findOne({ userID: director.userID });
const staffDiscord = this.server.client.users.get(director.userID) || await this.server.client.getRESTUser(director.userID); const staffDiscord = this.server.client.users.get(director.userID) || await this.server.client.getRESTUser(director.userID);
const staffInformation = await this.server.client.db.Staff.findOne({ userID: director.userID });
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Executive Order'); embed.setTitle('Executive Order');