mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
Add user route
This commit is contained in:
parent
a1823a750e
commit
ad9bd98933
4
src/routes/api/users/@me.js
Normal file
4
src/routes/api/users/@me.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
module.exports.get = fastify => ({
|
||||||
|
handler: req => req.user.payload,
|
||||||
|
onRequest: [fastify.authenticate],
|
||||||
|
});
|
@ -8,7 +8,7 @@ module.exports.get = () => ({
|
|||||||
} = await this.discord.getAccessTokenFromAuthorizationCodeFlow(req);
|
} = await this.discord.getAccessTokenFromAuthorizationCodeFlow(req);
|
||||||
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${access_token}` } })).json();
|
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${access_token}` } })).json();
|
||||||
const payload = {
|
const payload = {
|
||||||
avatar: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`,
|
avatar: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.webp`,
|
||||||
discriminator: user.discriminator,
|
discriminator: user.discriminator,
|
||||||
expiresAt: Date.now() + (expires_in * 1000),
|
expiresAt: Date.now() + (expires_in * 1000),
|
||||||
id: user.id,
|
id: user.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user