1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 18:53:29 +00:00

Added refresh token check for each API call. refactored logout messaging from authService

This commit is contained in:
Kyle Spearrin
2017-01-19 00:21:20 -05:00
parent 0b63eb58ba
commit 0bd77352b0
8 changed files with 159 additions and 76 deletions

View File

@@ -145,6 +145,23 @@ function initTokenService() {
return !(d.valueOf() > (new Date().valueOf() + (offsetSeconds * 1000)));
};
TokenService.prototype.tokenSecondsRemaining = function (offsetSeconds) {
var d = this.getTokenExpirationDate();
offsetSeconds = offsetSeconds || 0;
if (d === null) {
return 0;
}
var msRemaining = d.valueOf() - (new Date().valueOf() + (offsetSeconds * 1000));
return Math.round(msRemaining / 1000);
};
TokenService.prototype.tokenNeedsRefresh = function (minutes) {
minutes = minutes || 5; // default 5 minutes
var sRemaining = this.tokenSecondsRemaining();
return sRemaining < (60 * minutes);
};
TokenService.prototype.isTwoFactorScheme = function () {
return this.getScheme() !== 'Application';
};