From 31202b41e0f49d3551e2ba250aab37280c3f24ea Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Thu, 18 May 2017 15:30:03 +0200 Subject: [PATCH] Fallback to issued --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ce4a52f..8bdb28a 100644 --- a/src/index.js +++ b/src/index.js @@ -248,7 +248,8 @@ class Superlogin extends EventEmitter2 { if (!this._session || !this._session.user_id) { return Promise.reject(); } - const refreshed = this._session.refreshed; + // try getting the latest refresh date, if not available fall back to issued date + const refreshed = this._session.refreshed || this._session.issued; const expires = this._session.expires; const threshold = isNaN(this._config.refreshThreshold) ? 0.5 : this._config.refreshThreshold; const duration = expires - refreshed;