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 /src/index.ts | |
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 'src/index.ts')
-rw-r--r-- | src/index.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts index 4f4ad00..647038f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -132,7 +132,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 }) @@ -148,6 +153,8 @@ app.post('/accounts/session', async(req, res) => { try { const { uuid } = req.body const session = await fetchSession(uuid) + if (!session) + return res.json({ ok: false }) const account = await fetchAccountFromDiscord(session.discord_user.id) res.json({ session, account }) } catch (err) { |