mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
fix: infinite redirect when logging in
by setting `Same-Site=Lax`: https://bugs.chromium.org/p/chromium/issues/detail?id=696204#c41
This commit is contained in:
parent
6773d9ddbe
commit
757f77fb1d
@ -6,6 +6,8 @@ module.exports.get = () => ({
|
|||||||
access_token: accessToken,
|
access_token: accessToken,
|
||||||
expires_in: expiresIn,
|
expires_in: expiresIn,
|
||||||
} = await this.discord.getAccessTokenFromAuthorizationCodeFlow(req);
|
} = await this.discord.getAccessTokenFromAuthorizationCodeFlow(req);
|
||||||
|
const redirect = this.states.get(req.query.state) || '/';
|
||||||
|
this.states.delete(req.query.state);
|
||||||
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${accessToken}` } })).json();
|
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${accessToken}` } })).json();
|
||||||
const token = this.jwt.sign({
|
const token = this.jwt.sign({
|
||||||
accessToken,
|
accessToken,
|
||||||
@ -16,16 +18,14 @@ module.exports.get = () => ({
|
|||||||
locale: user.locale,
|
locale: user.locale,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
});
|
});
|
||||||
res
|
res.setCookie('token', token, {
|
||||||
.setCookie('token', token, {
|
domain,
|
||||||
domain,
|
httpOnly: true,
|
||||||
httpOnly: true,
|
maxAge: expiresIn,
|
||||||
maxAge: expiresIn,
|
path: '/',
|
||||||
path: '/',
|
sameSite: 'Lax',
|
||||||
sameSite: true,
|
secure: false,
|
||||||
secure: false,
|
});
|
||||||
})
|
return res.redirect(303, redirect);
|
||||||
.redirect(this.states.get(req.query.state) || '/');
|
|
||||||
this.states.delete(req.query.state);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user