Skip to content

Commit eca0648

Browse files
committed
fix(auth): 401 on private leaderboards
1 parent ebbf371 commit eca0648

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "axobot-api",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "A TypeScript API for the Axobot Discord bot",
55
"main": "index.js",
66
"scripts": {

src/modules/discord/utils/leaderboard.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ export async function getGuildInfo(guild: Guild): Promise<LeaderboardGuildData>
3838
}
3939

4040
export async function checkUserAuthentificationAndPermission(req: Request, res: Response): Promise<boolean> {
41-
const tokenCheckError = await tokenCheck(req);
42-
if (Array.isArray(tokenCheckError)) {
43-
res._err = tokenCheckError[1];
44-
res.status(tokenCheckError[0]).send(res._err);
41+
const tokenCheckResult = await tokenCheck(req);
42+
if (Array.isArray(tokenCheckResult)) { // is an error code and message
43+
res._err = tokenCheckResult[1];
44+
res.status(tokenCheckResult[0]).send(res._err);
4545
return false;
4646
}
47+
res.locals.user = tokenCheckResult;
4748
if (res.locals.user === undefined) {
4849
res._err = "Invalid token";
4950
res.status(401).send(res._err);

0 commit comments

Comments
 (0)