From 67dd68ecfa94100c94048346441cad76c7eefba1 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 8 Nov 2020 01:54:09 -0500 Subject: [PATCH] add info route --- src/api/routes/Webhook.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/api/routes/Webhook.ts b/src/api/routes/Webhook.ts index 9ee4cc4..64e525e 100644 --- a/src/api/routes/Webhook.ts +++ b/src/api/routes/Webhook.ts @@ -56,6 +56,21 @@ export default class Webhook extends Route { return res.sendStatus(200); }); + this.router.get('/info', async (req, res) => { + if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); + if (!req.query?.id) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR }); + + const account = await this.server.client.db.Account.findOne({ userID: req.query.id.toString() }).lean().exec(); + if (!account) return res.status(200).send({ found: false }); + + return res.status(200).send({ + found: true, + emailAddress: account.emailAddress, + tier: account.tier, + supportKey: account.supportKey, + }); + }); + this.router.get('/score', async (req, res) => { try { if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });