Merge branch 'vaultTimer'

This commit is contained in:
brantje 2017-01-09 14:04:30 +01:00
commit 0a81cb88ad
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
10 changed files with 119 additions and 9 deletions

View file

@ -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

View file

@ -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; }

View file

@ -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);
});
}]);
}());

View file

@ -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;

View file

@ -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 <http://www.gnu.org/licenses/>.
*
*/
(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;
};
});
}());

File diff suppressed because one or more lines are too long

View file

@ -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;

View file

@ -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');
?>
<div id="app" ng-app="passmanApp" ng-controller="MainCtrl">
<div id="logoutTimer"> </div>
<div class="warning_bar" ng-if="using_http && http_warning_hidden == false">
{{ 'http.warning' | translate }}
<i class="fa fa-times fa-2x" alt="Close" ng-click="setHttpWarning(true);"></i>
</div>
<div id="app-navigation" ng-if="selectedVault" ng-controller="MenuCtrl">
<div id="app-navigation" ng-show="selectedVault" ng-controller="MenuCtrl">
<ul>
<li class="taginput">
<a class="taginput">
@ -131,6 +132,7 @@ style('passman', 'app');
</a>
</li>
</ul>
<div id="app-settings" ng-init="settingsShown = false;">
<div id="app-settings-header">
<button class="settings-button"
@ -144,6 +146,9 @@ style('passman', 'app');
<div><a class="link" ng-href="#/vault/{{active_vault.guid}}/settings">{{ 'settings' | translate }}</a></div>
<div><span class="link" ng-click="logout()">{{'logout' | translate }}</span></div>
<div><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6YS8F97PETVU2" target="_blank" class="link">{{ 'donate' | translate }}</a></div>
<div ng-show="session_time_left">
<small>{{'session.time.left' | translate:translationData}}</small>
</div>
</div>
</div>
</div>

View file

@ -29,7 +29,7 @@
<input type="text" ng-model="filterOptions.filterText" class="searchbox" id="searchBox"
placeholder="{{'search.credential' | translate}}" select-on-click clear-btn ng-click="filterOptionShown = true;">
<div class="searchOptions" ng-show="filterOptionShown">
<input type="checkbox" ng-model="filterOptions.useRegex"> Use regex
<input type="checkbox" ng-model="filterOptions.useRegex"> {{ 'use.regex' | translate }}
</div>
</div>
<div class="viewModes">

View file

@ -111,6 +111,22 @@
{{ 'vault.auto.login' | translate}}
</label>
</div>
<div>
<label>
<input type="checkbox"
ng-checked="auto_logout_timer"
ng-click="toggleAutoLogout()">
{{ 'auto.logout' | translate}}
</label>
<select ng-model="logout_timer" ng-change="selectLogoutTimer(logout_timer)">
<option value="0">Never</option>
<option value="30">30 minutes</option>
<option value="60">60 minutes</option>
<option value="90">90 minutes</option>
<option value="180">3 hour</option>
<option value="480">8 hour</option>
</select>
</div>
</div>
<div class="button button-geen"
ng-click="loginToVault(list_selected_vault, vault_key)">