added lock now option
This commit is contained in:
parent
4861aa0210
commit
e079b70e6a
|
@ -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"
|
||||||
|
|
|
@ -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;
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue