diff options
author | mat <github@matdoes.dev> | 2021-06-29 17:54:50 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-29 17:54:50 -0500 |
commit | 49ff24343e1c964b6cb82fdf76957ffd2f27d049 (patch) | |
tree | 820a3668e21dffc7eefa53630944412d9d97a129 /src/index.ts | |
parent | 758ca15277daa11ce1ec86ce7f07ea7beee9eb8f (diff) | |
parent | c0c534dafb54ebf9f95a5054f576ad99de29f232 (diff) | |
download | skyblock-api-49ff24343e1c964b6cb82fdf76957ffd2f27d049.tar.gz skyblock-api-49ff24343e1c964b6cb82fdf76957ffd2f27d049.tar.bz2 skyblock-api-49ff24343e1c964b6cb82fdf76957ffd2f27d049.zip |
Merge branch 'main' of https://github.com/skyblockstats/skyblock-api into main
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) { |