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); + } + }); } }