fix: revoke token on logout

This commit is contained in:
Isaac 2023-03-10 23:42:39 +00:00
parent daadb5fe85
commit f55ee02ce5
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33

View File

@ -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],
});