From 94a13954a505be698a8c8e0f6a1035c45ed6eb73 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 11 Jul 2017 14:54:36 -0400 Subject: [PATCH] get premium status from token --- src/popup/app/vault/vaultViewLoginController.js | 4 ++-- src/services/tokenService.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/popup/app/vault/vaultViewLoginController.js b/src/popup/app/vault/vaultViewLoginController.js index e53af199..a0e47726 100644 --- a/src/popup/app/vault/vaultViewLoginController.js +++ b/src/popup/app/vault/vaultViewLoginController.js @@ -2,7 +2,7 @@ angular .module('bit.vault') .controller('vaultViewLoginController', function ($scope, $state, $stateParams, loginService, toastr, $q, - $analytics, i18nService, utilsService, totpService, $timeout) { + $analytics, i18nService, utilsService, totpService, $timeout, tokenService) { $scope.i18n = i18nService; var from = $stateParams.from, totpInterval = null; @@ -39,7 +39,7 @@ angular $scope.login.showLaunch = false; } - if (model.totp && (login.organizationUseTotp || false)) { + if (model.totp && (login.organizationUseTotp || tokenService.getPremium())) { totpUpdateCode(); totpTick(); diff --git a/src/services/tokenService.js b/src/services/tokenService.js index 4ee6a115..3f943d45 100644 --- a/src/services/tokenService.js +++ b/src/services/tokenService.js @@ -254,6 +254,16 @@ function initTokenService() { return decoded.name; }; + TokenService.prototype.getPremium = function () { + var decoded = this.decodeToken(); + + if (typeof decoded.premium === 'undefined') { + return false; + } + + return !!decoded.premium; + }; + TokenService.prototype.getIssuer = function () { var decoded = this.decodeToken();