From 329a4cce9cde58ff9d97e33a615a3a3e07362a3c Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 3 Oct 2020 21:02:40 -0400 Subject: [PATCH] fixes --- src/api/loc.sh/routes/internal.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/loc.sh/routes/internal.ts b/src/api/loc.sh/routes/internal.ts index d43847a..00d3294 100644 --- a/src/api/loc.sh/routes/internal.ts +++ b/src/api/loc.sh/routes/internal.ts @@ -212,5 +212,18 @@ export default class Internal extends Route { return this.handleError(err, res); } }); + + this.router.get('/pin', async (req, res) => { + try { + if (req.query?.auth.toString() !== this.server.client.config.internalKey) 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 report = await this.server.client.db.Score.findOne({ userID: req.query.id.toString() }); + if (!report) return res.status(404).json({ code: this.constants.codes.ACCOUNT_NOT_FOUND, message: this.constants.messages.NOT_FOUND }); + return res.status(200).json({ pin: report.pin }); + } catch (err) { + return this.handleError(err, res); + } + }); } }