Fixed authentication iffyness, it looks for the cookies insted of expecting them to be ordered right

master
masterhc 9 months ago
parent c1c54500cb
commit 87488ddbf2

@ -1358,7 +1358,7 @@ exports.DiscordAPI = class DiscordAPI
.then(result => result.json())
.then(response =>
{
console.log(response, this.authorization)
if(response.message) return response.message
return response.filter(x=>x.owner==true);
})
@ -1466,11 +1466,11 @@ exports.DiscordAPI = class DiscordAPI
}
AuthStringMaker(cookieString)
{
const splitCookie = cookieString.split('; ');
const tokenType = splitCookie[0].split('=')[1];
const accessToken = splitCookie[1].split('=')[1];
const accessToken = cookieParser(cookieString, 'accessToken');
const tokenType = cookieParser(cookieString, 'tokenType');
return `${tokenType} ${accessToken}`
}
/**
*
* @param {String} id GuildID
@ -1500,6 +1500,11 @@ exports.DiscordAPI = class DiscordAPI
}
}
exports.cookieParser = cookieParser = (cookie, name)=>
{
if(!cookie.includes(name)) return null
return cookie.split(name+'=')[1].split(';')[0];
}
/**
*
* @param {String|String} id - Discord Guild Id (GuildId) | Mongo Record ID (ruleID)

Loading…
Cancel
Save