diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-06-29 17:52:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 17:52:00 -0500 |
commit | c0c534dafb54ebf9f95a5054f576ad99de29f232 (patch) | |
tree | 8a8a81f5bd6fbb372899f769be402f0bec326149 /build/index.js | |
parent | 6c7d2de36be559f62560f00fc2297c7deec3a051 (diff) | |
download | skyblock-api-c0c534dafb54ebf9f95a5054f576ad99de29f232.tar.gz skyblock-api-c0c534dafb54ebf9f95a5054f576ad99de29f232.tar.bz2 skyblock-api-c0c534dafb54ebf9f95a5054f576ad99de29f232.zip |
enable strictNullChecks and fix all related issues (#65)
Diffstat (limited to 'build/index.js')
-rw-r--r-- | build/index.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/build/index.js b/build/index.js index 736b137..8bb2040 100644 --- a/build/index.js +++ b/build/index.js @@ -136,7 +136,12 @@ app.get('/constants', async (req, res) => { app.post('/accounts/createsession', async (req, res) => { try { const { code } = req.body; - const { access_token: accessToken, refresh_token: refreshToken } = await discord.exchangeCode(`${mainSiteUrl}/loggedin`, code); + const codeExchange = await discord.exchangeCode(`${mainSiteUrl}/loggedin`, code); + if (!codeExchange) { + res.json({ ok: false, error: 'discord_client_secret isn\'t in env' }); + return; + } + const { access_token: accessToken, refresh_token: refreshToken } = codeExchange; if (!accessToken) // access token is invalid :( return res.json({ ok: false }); @@ -152,6 +157,8 @@ app.post('/accounts/session', async (req, res) => { try { const { uuid } = req.body; const session = await database_1.fetchSession(uuid); + if (!session) + return res.json({ ok: false }); const account = await database_1.fetchAccountFromDiscord(session.discord_user.id); res.json({ session, account }); } |