diff --git a/src/popup/app/config.js b/src/popup/app/config.js index 624f44a9..c4340a90 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -11,7 +11,24 @@ $urlRouterProvider.otherwise(function ($injector, $location) { var $state = $injector.get('$state'); - $state.go('home'); + var userService = $injector.get('userService'); + var cryptoService = $injector.get('cryptoService'); + + cryptoService.getKey(false, function (key) { + userService.isAuthenticated(function (isAuthenticated) { + if (isAuthenticated) { + if (!key) { + $state.go('lock'); + } + else { + $state.go('tabs.current'); + } + } + else { + $state.go('home'); + } + }); + }); }); $stateProvider @@ -190,39 +207,22 @@ params: { animation: null } }); }) - .run(function ($rootScope, userService, cryptoService, tokenService, $state, constantsService, stateService) { + .run(function ($rootScope, userService, $state, constantsService, stateService) { $rootScope.$on('$stateChangeStart', function (event, toState, toParams) { if ($state.current.name.indexOf('tabs.') > -1 && toState.name.indexOf('tabs.') > -1) { stateService.purgeState(); } - cryptoService.getKey(false, function (key) { - userService.isAuthenticated(function (isAuthenticated) { - if (isAuthenticated) { - var obj = {}; - obj[constantsService.lastActiveKey] = (new Date()).getTime(); - chrome.storage.local.set(obj, function () { }); - } - - if (!toState.data || !toState.data.authorize) { - if (isAuthenticated && !tokenService.isTokenExpired()) { - event.preventDefault(); - if (!key) { - $state.go('lock'); - } - else { - $state.go('tabs.current'); - } - } - - return; - } - - if (!isAuthenticated || tokenService.isTokenExpired()) { - event.preventDefault(); - chrome.runtime.sendMessage({ command: 'logout' }); - } - }); + userService.isAuthenticated(function (isAuthenticated) { + if (isAuthenticated) { + var obj = {}; + obj[constantsService.lastActiveKey] = (new Date()).getTime(); + chrome.storage.local.set(obj, function () { }); + } + else if (toState.data && toState.data.authorize) { + event.preventDefault(); + chrome.runtime.sendMessage({ command: 'logout' }); + } }); }); }); diff --git a/src/popup/app/settings/settingsController.js b/src/popup/app/settings/settingsController.js index 3277e7ba..e21b70cf 100644 --- a/src/popup/app/settings/settingsController.js +++ b/src/popup/app/settings/settingsController.js @@ -14,6 +14,8 @@ else { $scope.lockOption = ''; } + + $scope.$apply(); }); $scope.changeLockOption = function () { diff --git a/src/popup/app/vault/views/vaultViewLogin.html b/src/popup/app/vault/views/vaultViewLogin.html index 5c62da6c..f812c56a 100644 --- a/src/popup/app/vault/views/vaultViewLogin.html +++ b/src/popup/app/vault/views/vaultViewLogin.html @@ -28,7 +28,7 @@