diff --git a/controller/translationcontroller.php b/controller/translationcontroller.php index a60e6abd..a944c887 100644 --- a/controller/translationcontroller.php +++ b/controller/translationcontroller.php @@ -304,7 +304,7 @@ class TranslationController extends ApiController { 'revisions' => $this->trans->t('Revisions'), 'recover' => $this->trans->t('Recover'), 'destroy' => $this->trans->t('Destroy'), - + 'use.regex' => $this->trans->t('Use regex'), 'sharereq.title' => $this->trans->t('You have incoming share requests.'), 'sharereq.line1' => $this->trans->t('If you want to put the credential in a other vault,'), 'sharereq.line2' => $this->trans->t('logout of this vault and login to the vault you want the shared credential in.'), @@ -313,6 +313,7 @@ class TranslationController extends ApiController { 'date' => $this->trans->t('Date'), 'accept' => $this->trans->t('Accept'), 'decline' => $this->trans->t('Decline'), + 'session.time.left' => $this->trans->t('You have {{session_time}} left before logout.'), // templates/views/vaults.html 'last.access' => $this->trans->t('Last accessed'), @@ -329,6 +330,7 @@ class TranslationController extends ApiController { 'input.vault.password' => $this->trans->t('Please input the password for'), 'vault.default' => $this->trans->t('Set this vault as default.'), 'vault.auto.login' => $this->trans->t('Login automatically to this vault.'), + 'auto.logout' => $this->trans->t('Logout of this vault automatically after: '), 'vault.decrypt' => $this->trans->t('Decrypt vault'), // templates/bookmarklet.php diff --git a/css/app.css b/css/app.css index f1e6e3e9..01c4364e 100644 --- a/css/app.css +++ b/css/app.css @@ -877,7 +877,7 @@ height: 200px; } #app-settings-content:not(.ng-hide) { - height: 60px; + height: 90px; display: inherit !important; padding: 0; transition: height 0.15s ease-out; } diff --git a/js/app/controllers/main.js b/js/app/controllers/main.js index 78d97bb2..b8f2dbbd 100644 --- a/js/app/controllers/main.js +++ b/js/app/controllers/main.js @@ -31,7 +31,7 @@ * Controller of the passmanApp */ angular.module('passmanApp') - .controller('MainCtrl', ['$scope', '$rootScope', '$location', 'SettingsService', function ($scope, $rootScope, $location, SettingsService) { + .controller('MainCtrl', ['$scope', '$rootScope', '$location', 'SettingsService', '$window', '$interval', '$filter', function ($scope, $rootScope, $location, SettingsService, $window, $interval, $filter) { $scope.selectedVault = false; $scope.http_warning_hidden = true; @@ -63,6 +63,30 @@ $rootScope.$on('logout', function () { $scope.selectedVault = false; }); + + var tickSessionTimer = function(){ + if($scope.session_time_left){ + $scope.session_time_left--; + var session_time_left_formatted = $filter('toHHMMSS')($scope.session_time_left); + $scope.translationData = { + session_time: session_time_left_formatted + }; + $rootScope.$broadcast('logout_timer_tick_tack', $scope.session_time_left); + if($scope.session_time_left === 0){ + $window.location.reload(); + } + } + }; + + $scope.session_time_left = false; + $scope.$on('logout_timer_set', function(evt, timer){ + $scope.session_time_left = timer; + $scope.translationData = { + session_time: timer + }; + $interval(tickSessionTimer, 1000); + }); + }]); }()); \ No newline at end of file diff --git a/js/app/controllers/vault.js b/js/app/controllers/vault.js index 99a868d4..08b3f7ca 100644 --- a/js/app/controllers/vault.js +++ b/js/app/controllers/vault.js @@ -67,6 +67,8 @@ $scope.default_vault = false; $scope.remember_vault_password = false; + $scope.auto_logout_timer = false; + $scope.logout_timer = '0'; $scope.list_selected_vault = false; $scope.minimal_value_key_strength = 3; @@ -98,6 +100,10 @@ } }; + $scope.toggleAutoLogout = function(){ + $scope.auto_logout_timer = !$scope.auto_logout_timer; + }; + $scope.clearState = function () { $scope.list_selected_vault = false; $scope.creating_vault = false; @@ -131,10 +137,20 @@ var _vault = angular.copy(vault); _vault.vaultKey = angular.copy(vault_key); delete _vault.credentials; + var timer = parseInt($scope.logout_timer); + if($scope.auto_logout_timer && timer > 0 ){ + $rootScope.$broadcast('logout_timer_set', timer*60); + } + VaultService.setActiveVault(_vault); $location.path('/vault/' + vault.guid); }; + $scope.selectLogoutTimer = function (time) { + $scope.auto_logout_timer = true; + $scope.logout_timer = time; + }; + $scope.vaultDecryptionKey = ''; $scope.loginToVault = function (vault, vault_key) { $scope.error = false; diff --git a/js/app/filters/toHHMMSS.js b/js/app/filters/toHHMMSS.js new file mode 100644 index 00000000..d7e4e4c2 --- /dev/null +++ b/js/app/filters/toHHMMSS.js @@ -0,0 +1,47 @@ +/** + * Nextcloud - passman + * + * @copyright Copyright (c) 2016, Sander Brand (brantje@gmail.com) + * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel (wolfi@wolfi.es) + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +(function () { + 'use strict'; + /** + * @ngdoc filter + * @name passmanApp.filter:decrypt + * @function + * @description + * # decrypt + * Filter in the passmanApp. + */ + angular.module('passmanApp') + .filter('toHHMMSS', function () { + return function (_seconds) { + var sec_num = parseInt(_seconds, 10); // don't forget the second param + var hours = Math.floor(sec_num / 3600); + var minutes = Math.floor((sec_num - (hours * 3600)) / 60); + var seconds = sec_num - (hours * 3600) - (minutes * 60); + + if (hours < 10) {hours = "0"+hours;} + if (minutes < 10) {minutes = "0"+minutes;} + if (seconds < 10) {seconds = "0"+seconds;} + return hours+':'+minutes+':'+seconds; + }; + }); +}()); \ No newline at end of file diff --git a/js/templates.js b/js/templates.js index 3ed9098c..55719e1d 100644 --- a/js/templates.js +++ b/js/templates.js @@ -113,12 +113,12 @@ angular.module('views/share_credential.html', []).run(['$templateCache', functio angular.module('views/show_vault.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/show_vault.html', - '
{{ \'deleted.since\' | translate }}: All time {{delete_time | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
+
Use regex
{{ ::tag.text}} {{ ::credential.label}}
  • {{ ::credential.label}}
    {{ ::tag.text}}

{{selectedCredential.label}}

{{ \'account\' | translate }}
{{ \'password\' | translate }}
{{\'otp\' | translate}}
{{\'email\' | translate}}
{{ \'url\' | translate}}
{{\'notes\' | translate}}
{{ \'files\' | translate}}
{{field.label}}
{{field.value.filename}} ({{field.value.size | bytes}})
{{ \'expire.time\' | translate }}
{{selectedCredential.expire_time * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
{{ \'changed\' | translate}}
{{selectedCredential.changed * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
{{ \'created\' | translate}}
{{selectedCredential.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
{{tag.text}}
'); }]); angular.module('views/vaults.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/vaults.html', - '
  • + Create a new vault
  • {{vault.name}}
    {{ \'created\' | translate}}: {{vault.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}} | {{ \'last.access\' | translate}}: {{vault.last_access * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}} {{\'never\' | translate}}
  • {{ \'no.vaults\' | translate}}
  • {{ \'go.back.vaults\' | translate }}
'); + '
  • + Create a new vault
  • {{vault.name}}
    {{ \'created\' | translate}}: {{vault.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}} | {{ \'last.access\' | translate}}: {{vault.last_access * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}} {{\'never\' | translate}}
  • {{ \'no.vaults\' | translate}}
  • {{ \'go.back.vaults\' | translate }}
'); }]); diff --git a/sass/app.scss b/sass/app.scss index 85e7049a..f8d384fb 100644 --- a/sass/app.scss +++ b/sass/app.scss @@ -33,7 +33,7 @@ @import 'settings'; #app-settings-content:not(.ng-hide) { - height: 60px; + height: 90px; display: inherit !important; padding: 0; transition: height 0.15s ease-out; diff --git a/templates/main.php b/templates/main.php index 801196c9..7109179e 100644 --- a/templates/main.php +++ b/templates/main.php @@ -51,6 +51,7 @@ script('passman', 'app/filters/byte'); script('passman', 'app/filters/tagfilter'); script('passman', 'app/filters/as'); script('passman', 'app/filters/credentialsearch'); +script('passman', 'app/filters/toHHMMSS'); script('passman', 'app/services/cacheservice'); script('passman', 'app/services/vaultservice'); script('passman', 'app/services/credentialservice'); @@ -104,13 +105,13 @@ style('passman', 'app'); ?>
- +
{{ 'http.warning' | translate }}
-
+
+
{{'logout' | translate }}
+
+ {{'session.time.left' | translate:translationData}} +
diff --git a/templates/views/show_vault.html b/templates/views/show_vault.html index 174f6f3f..9821c394 100644 --- a/templates/views/show_vault.html +++ b/templates/views/show_vault.html @@ -29,7 +29,7 @@
- Use regex + {{ 'use.regex' | translate }}
diff --git a/templates/views/vaults.html b/templates/views/vaults.html index 26080899..17a45e28 100644 --- a/templates/views/vaults.html +++ b/templates/views/vaults.html @@ -111,6 +111,22 @@ {{ 'vault.auto.login' | translate}}
+
+ + +