[Server/auth] use better expiresAt matching

This commit is contained in:
41666 2019-05-05 12:58:40 -05:00
parent 9299b65575
commit 0d97ad2355
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF
2 changed files with 2 additions and 6 deletions

View file

@ -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)

View file

@ -22,8 +22,6 @@ class SessionsService extends Service {
session = this.Session.build({ id })
}
console.log(maxAge)
session.data = data
session.maxAge = maxAge