pull/29/head
Matthew 2020-10-03 21:02:40 -04:00
parent c34d193939
commit 329a4cce9c
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 13 additions and 0 deletions

View File

@ -212,5 +212,18 @@ export default class Internal extends Route {
return this.handleError(err, res); 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);
}
});
} }
} }