Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-Santana-j committed Apr 27, 2024
1 parent 8731651 commit 4c6b4aa
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ app.get('/auth/callback', async (req, res) => {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'application/x-www-form-urlencoded'
};
const response = await axios.post('https://discord.com/api/oauth2/token', param, { headers }).then((res) => { return res }).catch((err) => {
res.redirect('/logout')
const response = await axios.post('https://discord.com/api/oauth2/token', param, { headers }).then((res) => { return res }).catch((err) => {
console.error(err)})
if (!response) {
res.redirect('/logout')
Expand All @@ -179,7 +178,6 @@ app.get('/auth/callback', async (req, res) => {
...headers
}
}).then((res) => { return res.data }).catch((err) => {
res.redirect('/logout')
console.error(err)
});
await db.create('users', userResponse.id, {
Expand All @@ -204,16 +202,21 @@ app.get('/auth/callback', async (req, res) => {


app.get('/logout', async (req, res) => {
if (req.session.uid) {
const sessionID = req.session.id;
req.sessionStore.destroy(sessionID, (err) => {
if (err) {
return console.error(err)
} else {
res.redirect('/')
}
})

try {
if (req.session.uid) {
const sessionID = req.session.id;
req.sessionStore.destroy(sessionID, (err) => {
if (err) {
return console.error(err)
} else {
res.redirect('/')
}
})
}else{
res.redirect('/')
}
} catch (error) {
res.redirect('/')
}
})

Expand Down

0 comments on commit 4c6b4aa

Please sign in to comment.