From bdf5c9275fa138129cc2bc8c293be2ad81fe3924 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 8 May 2015 15:54:12 +0100 Subject: [PATCH] Change session length to 7 days refs #5202 - this is just a stopgap to deliver minor improvement short term, - longer term we will do the work to refresh refresh tokens & switch this to a month --- core/server/middleware/oauth.js | 4 ++-- core/server/utils/index.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/server/middleware/oauth.js b/core/server/middleware/oauth.js index d284532432..07cdfb1799 100644 --- a/core/server/middleware/oauth.js +++ b/core/server/middleware/oauth.js @@ -32,7 +32,7 @@ oauth = { var accessToken = utils.uid(256), refreshToken = utils.uid(256), accessExpires = Date.now() + utils.ONE_HOUR_MS, - refreshExpires = Date.now() + utils.ONE_DAY_MS; + refreshExpires = Date.now() + utils.ONE_WEEK_MS; return models.Accesstoken.add({token: accessToken, user_id: user.id, client_id: client.id, expires: accessExpires}).then(function () { return models.Refreshtoken.add({token: refreshToken, user_id: user.id, client_id: client.id, expires: refreshExpires}); @@ -62,7 +62,7 @@ oauth = { var token = model.toJSON(), accessToken = utils.uid(256), accessExpires = Date.now() + utils.ONE_HOUR_MS, - refreshExpires = Date.now() + utils.ONE_DAY_MS; + refreshExpires = Date.now() + utils.ONE_WEEK_MS; if (token.expires > Date.now()) { models.Accesstoken.add({ diff --git a/core/server/utils/index.js b/core/server/utils/index.js index 8179f769a5..9a944be123 100644 --- a/core/server/utils/index.js +++ b/core/server/utils/index.js @@ -19,13 +19,14 @@ utils = { /** * Timespans in seconds and milliseconds for better readability */ - ONE_HOUR_S: 3600, - ONE_DAY_S: 86400, - ONE_YEAR_S: 31536000, - ONE_HOUR_MS: 3600000, - ONE_DAY_MS: 86400000, - ONE_MONTH_MS: 2628000000, - ONE_YEAR_MS: 31536000000, + ONE_HOUR_S: 3600, + ONE_DAY_S: 86400, + ONE_YEAR_S: 31536000, + ONE_HOUR_MS: 3600000, + ONE_DAY_MS: 86400000, + ONE_WEEK_MS: 604800000, + ONE_MONTH_MS: 2628000000, + ONE_YEAR_MS: 31536000000, /** * Return a unique identifier with the given `len`.