added lock now option

This commit is contained in:
Kyle Spearrin 2017-06-13 11:53:08 -04:00
parent 4861aa0210
commit e079b70e6a
5 changed files with 29 additions and 8 deletions

View File

@ -399,6 +399,10 @@
"message": "Lock Options", "message": "Lock Options",
"description": "Lock Options" "description": "Lock Options"
}, },
"lockNow": {
"message": "Lock Now",
"description": "Lock Now"
},
"immediately": { "immediately": {
"message": "Immediately", "message": "Immediately",
"description": "Immediately" "description": "Immediately"

View File

@ -42,4 +42,7 @@
}) })
.factory('settingsService', function () { .factory('settingsService', function () {
return chrome.extension.getBackgroundPage().settingsService; return chrome.extension.getBackgroundPage().settingsService;
})
.factory('lockService', function () {
return chrome.extension.getBackgroundPage().lockService;
}); });

View File

@ -2,7 +2,7 @@
.module('bit.settings') .module('bit.settings')
.controller('settingsController', function ($scope, $state, SweetAlert, utilsService, $analytics, .controller('settingsController', function ($scope, $state, SweetAlert, utilsService, $analytics,
i18nService, constantsService, cryptoService) { i18nService, constantsService, cryptoService, lockService) {
utilsService.initListSectionItemListeners($(document), angular); utilsService.initListSectionItemListeners($(document), angular);
$scope.lockOption = ''; $scope.lockOption = '';
$scope.i18n = i18nService; $scope.i18n = i18nService;
@ -48,6 +48,14 @@
}); });
}; };
$scope.lock = function () {
lockService.lock().then(function () {
return $state.go('lock', {
animation: 'in-slide-up'
});
});
};
$scope.logOut = function () { $scope.logOut = function () {
SweetAlert.swal({ SweetAlert.swal({
title: i18nService.logOut, title: i18nService.logOut,
@ -114,13 +122,13 @@
case 'chrome': case 'chrome':
chrome.tabs.create({ chrome.tabs.create({
url: 'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/' + url: 'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/' +
'nngceckbapebfimnlniiiahkandclblb/reviews' 'nngceckbapebfimnlniiiahkandclblb/reviews'
}); });
break; break;
case 'firefox': case 'firefox':
chrome.tabs.create({ chrome.tabs.create({
url: 'https://addons.mozilla.org/en-US/firefox/addon/' + url: 'https://addons.mozilla.org/en-US/firefox/addon/' +
'bitwarden-password-manager/#reviews' 'bitwarden-password-manager/#reviews'
}); });
break; break;
case 'edge': case 'edge':
@ -129,7 +137,7 @@
case 'opera': case 'opera':
chrome.tabs.create({ chrome.tabs.create({
url: 'https://addons.opera.com/en/extensions/details/' + url: 'https://addons.opera.com/en/extensions/details/' +
'bitwarden-free-password-manager/#feedback-container' 'bitwarden-free-password-manager/#feedback-container'
}); });
break; break;
default: default:

View File

@ -23,6 +23,10 @@
<option value="">{{i18n.never}}</option> <option value="">{{i18n.never}}</option>
</select> </select>
</div> </div>
<a class="list-section-item" href="" ng-click="lock()">
{{i18n.lockNow}}
<i class="fa fa-chevron-right fa-lg"></i>
</a>
<a class="list-section-item" href="" ng-click="twoStep()"> <a class="list-section-item" href="" ng-click="twoStep()">
{{i18n.twoStepLogin}} {{i18n.twoStepLogin}}
<i class="fa fa-chevron-right fa-lg"></i> <i class="fa fa-chevron-right fa-lg"></i>

View File

@ -50,7 +50,7 @@ function initLockService(self) {
var diffSeconds = ((new Date()).getTime() - lastActive) / 1000; var diffSeconds = ((new Date()).getTime() - lastActive) / 1000;
if (diffSeconds >= lockOptionSeconds) { if (diffSeconds >= lockOptionSeconds) {
// need to lock now // need to lock now
self.lock(); return self.lock();
} }
}); });
} }
@ -59,16 +59,18 @@ function initLockService(self) {
chrome.idle.onStateChanged.addListener(function (newState) { chrome.idle.onStateChanged.addListener(function (newState) {
if (newState === 'locked') { if (newState === 'locked') {
getLockOption().then(function (lockOption) { getLockOption().then(function (lockOption) {
if (lockOption === -2) { if (lockOption !== -2) {
self.lock(); return;
} }
return self.lock();
}); });
} }
}); });
} }
LockService.prototype.lock = function () { LockService.prototype.lock = function () {
Q.all([ return Q.all([
self.cryptoService.clearKey(), self.cryptoService.clearKey(),
self.cryptoService.clearOrgKeys(true), self.cryptoService.clearOrgKeys(true),
self.cryptoService.clearPrivateKey(true) self.cryptoService.clearPrivateKey(true)