From e6915a35a7f89a1c363fac8f1ab9b4a2aa865252 Mon Sep 17 00:00:00 2001 From: brantje Date: Sat, 24 Sep 2016 10:59:16 +0200 Subject: [PATCH] Add revision controller --- js/app/controllers/revision.js | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 js/app/controllers/revision.js diff --git a/js/app/controllers/revision.js b/js/app/controllers/revision.js new file mode 100644 index 00000000..a508bec8 --- /dev/null +++ b/js/app/controllers/revision.js @@ -0,0 +1,46 @@ +'use strict'; + +/** + * @ngdoc function + * @name passmanApp.controller:RevisionCtrl + * @description + * # RevisionCtrl + * Controller of the passmanApp + */ +angular.module('passmanApp') + .controller('RevisionCtrl', ['$scope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', function ($scope, SettingsService, VaultService, CredentialService, $location, $routeParams) { + + if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) { + if (!$scope.active_vault) { + $location.path('/') + } + } else { + if (SettingsService.getSetting('defaultVault') && SettingsService.getSetting('defaultVaultPass')) { + var _vault = angular.copy(SettingsService.getSetting('defaultVault')); + _vault.vaultKey = angular.copy(SettingsService.getSetting('defaultVaultPass')); + VaultService.setActiveVault(_vault); + $scope.active_vault = _vault; + + } + } + if ($scope.active_vault) { + $scope.$parent.selectedVault = true; + } + var storedCredential = SettingsService.getSetting('edit_credential'); + + if (!storedCredential) { + CredentialService.getCredential($routeParams.credential_id).then(function(result){ + $scope.storedCredential = CredentialService.decryptCredential(angular.copy(result)); + }); + } else { + $scope.storedCredential = CredentialService.decryptCredential(angular.copy(storedCredential)); + } + + $scope.cancel = function () { + $location.path('/vault/' + $routeParams.vault_id); + $scope.storedCredential = null; + SettingsService.setSetting('revision_credential', null); + } + + }]); +