mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +02:00
fix(api): logout (#415)
* Fixed logout Fixed users can't logout * Update logout.js * Fix ESLint
This commit is contained in:
parent
b2a8b039df
commit
d577b9d057
@ -1,13 +1,22 @@
|
|||||||
|
const { domain } = require('../../lib/http');
|
||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async function (req, res) {
|
handler: async function (req, res) {
|
||||||
|
const { accessToken } = req.user;
|
||||||
|
|
||||||
await fetch('https://discord.com/api/oauth2/token/revoke', {
|
await fetch('https://discord.com/api/oauth2/token/revoke', {
|
||||||
body: new URLSearchParams({ token: req.user.accessToken }).toString(),
|
body: new URLSearchParams({ token: accessToken }).toString(),
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
res
|
|
||||||
.clearCookie('token', '/')
|
res.clearCookie('token', {
|
||||||
.send('The token has been revoked.');
|
domain,
|
||||||
|
httpOnly: true,
|
||||||
|
path: '/',
|
||||||
|
sameSite: 'Lax',
|
||||||
|
secure: false,
|
||||||
|
}).send('The token has been revoked.');
|
||||||
},
|
},
|
||||||
onRequest: [fastify.authenticate],
|
onRequest: [fastify.authenticate],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user