Skip to content

Commit

Permalink
perf: prevent crash when malformed token is submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
zapteryx committed Dec 30, 2022
1 parent ec353ec commit e204860
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/events/web/fetchuser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ export default {
token?: string,
): Promise<void> {
if (!token) return;
const decryptedToken = CryptoJS.AES.decrypt(
token,
settings.features.web.encryptionKey,
).toString(CryptoJS.enc.Utf8);
let decryptedToken;
try {
decryptedToken = CryptoJS.AES.decrypt(
token,
settings.features.web.encryptionKey,
).toString(CryptoJS.enc.Utf8);
} catch (error) {
return callback({ status: 'error-generic' });
}
const user = await request('https://discord.com/api/users/@me', {
headers: {
Authorization: decryptedToken,
Expand Down

0 comments on commit e204860

Please sign in to comment.