File tree Expand file tree Collapse file tree
src/modules/discord/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change @@ -38,12 +38,13 @@ export async function getGuildInfo(guild: Guild): Promise<LeaderboardGuildData>
3838}
3939
4040export 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 ) ;
You can’t perform that action at this time.
0 commit comments