diff --git a/src/routes/auth/logout.js b/src/routes/auth/logout.js index 4e5910c..82677f6 100644 --- a/src/routes/auth/logout.js +++ b/src/routes/auth/logout.js @@ -1,7 +1,13 @@ -module.exports.get = () => ({ +module.exports.get = fastify => ({ handler: async function (req, res) { + await fetch('https://discord.com/api/oauth2/token/revoke', { + body: new URLSearchParams({ token: req.user.payload.accessToken }).toString(), + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + method: 'POST', + }); res .clearCookie('token', '/') - .send('Logged out.'); + .send('The token has been revoked.'); }, + onRequest: [fastify.authenticate], }); \ No newline at end of file