mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-25 04:09:12 +00:00
[Server/auth] use better expiresAt matching
This commit is contained in:
parent
9299b65575
commit
0d97ad2355
2 changed files with 2 additions and 6 deletions
|
@ -8,13 +8,11 @@ module.exports = (R, $) => {
|
|||
return
|
||||
}
|
||||
|
||||
console.log(ctx.session.expiresAt >= new Date(), ctx.session.expiresAt, new Date())
|
||||
|
||||
if (ctx.session.accessToken === undefined || ctx.session.expiresAt >= new Date()) {
|
||||
if (ctx.session.accessToken === undefined || ctx.session.expiresAt < Date.now()) {
|
||||
const data = await $.discord.getAuthToken(token)
|
||||
ctx.session.accessToken = data.access_token
|
||||
ctx.session.refreshToken = data.refresh_token
|
||||
ctx.session.expiresAt = new Date() + ctx.expires_in
|
||||
ctx.session.expiresAt = Date.now() + (ctx.expires_in || 1000 * 60 * 60 * 24)
|
||||
}
|
||||
|
||||
const user = await $.discord.getUser(ctx.session.accessToken)
|
||||
|
|
|
@ -22,8 +22,6 @@ class SessionsService extends Service {
|
|||
session = this.Session.build({ id })
|
||||
}
|
||||
|
||||
console.log(maxAge)
|
||||
|
||||
session.data = data
|
||||
session.maxAge = maxAge
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue