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:
@@ -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';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user