mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
Added setting to not store key via lock options, only keeping it in memory. Fixed some i18n and created constants service
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<button type="submit" class="btn btn-link" ng-show="!theForm.$loading">{{i18n.login}}</button>
|
||||
<i class="fa fa-spinner fa-lg" ng-show="theForm.$loading" ng-class="{'fa-spin' : theForm.$loading}"></i>
|
||||
</div>
|
||||
<div class="title">{{i18n.bitwarden}}</div>
|
||||
<div class="title">{{i18n.appName}}</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="list">
|
||||
|
||||
@@ -14,5 +14,6 @@
|
||||
'bit.current',
|
||||
'bit.vault',
|
||||
'bit.settings',
|
||||
'bit.tools'
|
||||
'bit.tools',
|
||||
'bit.lock'
|
||||
]);
|
||||
|
||||
@@ -163,27 +163,41 @@
|
||||
controller: 'settingsEditFolderController',
|
||||
data: { authorize: true },
|
||||
params: { animation: null }
|
||||
})
|
||||
.state('lock', {
|
||||
url: '/lock',
|
||||
templateUrl: 'app/lock/views/lock.html',
|
||||
controller: 'lockController',
|
||||
data: { authorize: true },
|
||||
params: { animation: null }
|
||||
});
|
||||
})
|
||||
.run(function ($rootScope, userService, loginService, tokenService, $state) {
|
||||
.run(function ($rootScope, userService, loginService, cryptoService, tokenService, $state) {
|
||||
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
|
||||
tokenService.getToken(function (token) {
|
||||
userService.isAuthenticated(function (isAuthenticated) {
|
||||
if (!toState.data || !toState.data.authorize) {
|
||||
if (isAuthenticated && !tokenService.isTokenExpired(token)) {
|
||||
event.preventDefault();
|
||||
$state.go('tabs.current');
|
||||
cryptoService.getKey(false, function (key) {
|
||||
tokenService.getToken(function (token) {
|
||||
userService.isAuthenticated(function (isAuthenticated) {
|
||||
if (!toState.data || !toState.data.authorize) {
|
||||
if (isAuthenticated && !tokenService.isTokenExpired(token)) {
|
||||
event.preventDefault();
|
||||
if (!key) {
|
||||
$state.go('lock');
|
||||
}
|
||||
else {
|
||||
$state.go('tabs.current');
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAuthenticated || tokenService.isTokenExpired(token)) {
|
||||
event.preventDefault();
|
||||
loginService.logOut(function () {
|
||||
$state.go('home');
|
||||
});
|
||||
}
|
||||
if (!isAuthenticated || tokenService.isTokenExpired(token)) {
|
||||
event.preventDefault();
|
||||
loginService.logOut(function () {
|
||||
$state.go('home');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
45
src/popup/app/lock/lockController.js
Normal file
45
src/popup/app/lock/lockController.js
Normal file
@@ -0,0 +1,45 @@
|
||||
angular
|
||||
.module('bit.lock')
|
||||
|
||||
.controller('lockController', function ($scope, $state, $analytics, i18nService, loginService, cryptoService, toastr,
|
||||
userService, SweetAlert) {
|
||||
$scope.i18n = i18nService;
|
||||
$('#master-password').focus();
|
||||
|
||||
$scope.logOut = function () {
|
||||
loginService.logOut(function () {
|
||||
SweetAlert.swal({
|
||||
title: 'Log Out',
|
||||
text: 'Are you sure you want to log out?',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Yes',
|
||||
cancelButtonText: 'Cancel'
|
||||
}, function (confirmed) {
|
||||
if (confirmed) {
|
||||
loginService.logOut(function () {
|
||||
$analytics.eventTrack('Logged Out');
|
||||
$state.go('home');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.submit = function () {
|
||||
userService.getEmail(function (email) {
|
||||
var key = cryptoService.makeKey($scope.masterPassword, email);
|
||||
cryptoService.hashPassword($scope.masterPassword, key, function (keyHash) {
|
||||
cryptoService.getKeyHash(true, function (storedKeyHash) {
|
||||
if (storedKeyHash && keyHash && storedKeyHash === keyHash) {
|
||||
cryptoService.setKey(key, function () {
|
||||
$state.go('tabs.current');
|
||||
});
|
||||
}
|
||||
else {
|
||||
toastr.error(i18nService.invalidMasterPassword, i18nService.errorsHaveOccurred);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
2
src/popup/app/lock/lockModule.js
Normal file
2
src/popup/app/lock/lockModule.js
Normal file
@@ -0,0 +1,2 @@
|
||||
angular
|
||||
.module('bit.lock', ['ngAnimate', 'toastr']);
|
||||
25
src/popup/app/lock/views/lock.html
Normal file
25
src/popup/app/lock/views/lock.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<form name="theForm" ng-submit="submit()" bit-form="submitPromise">
|
||||
<div class="header">
|
||||
<div class="right">
|
||||
<button type="submit" class="btn btn-link">{{i18n.submit}}</button>
|
||||
</div>
|
||||
<div class="title">{{i18n.verifyMasterPassword}}</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="list">
|
||||
<div class="list-section">
|
||||
<div class="list-section-items">
|
||||
<div class="list-section-item list-section-item-icon-input">
|
||||
<i class="fa fa-lock fa-lg fa-fw"></i>
|
||||
<label for="master-password" class="sr-only">{{i18n.masterPass}}</label>
|
||||
<input id="master-password" type="password" name="MasterPassword" placeholder="{{i18n.masterPass}}"
|
||||
ng-model="masterPassword">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-center text-accent">
|
||||
<a ng-click="logOut()" href="">{{i18n.logOut}}</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
@@ -39,4 +39,7 @@
|
||||
})
|
||||
.factory('i18nService', function () {
|
||||
return chrome.extension.getBackgroundPage().i18nService;
|
||||
})
|
||||
.factory('constantsService', function () {
|
||||
return chrome.extension.getBackgroundPage().constantsService;
|
||||
});
|
||||
|
||||
@@ -19,17 +19,19 @@
|
||||
|
||||
tokenService.setToken(response.token, function () {
|
||||
cryptoService.setKey(key, function () {
|
||||
if (response.profile) {
|
||||
userService.setUserId(response.profile.id, function () {
|
||||
userService.setEmail(response.profile.email, function () {
|
||||
chrome.runtime.sendMessage({ command: 'loggedIn' });
|
||||
deferred.resolve(response);
|
||||
cryptoService.setKeyHash(hashedPassword, function () {
|
||||
if (response.profile) {
|
||||
userService.setUserId(response.profile.id, function () {
|
||||
userService.setEmail(response.profile.email, function () {
|
||||
chrome.runtime.sendMessage({ command: 'loggedIn' });
|
||||
deferred.resolve(response);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
deferred.resolve(response);
|
||||
}
|
||||
}
|
||||
else {
|
||||
deferred.resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}, function (error) {
|
||||
@@ -68,14 +70,16 @@
|
||||
userService.getUserId(function (userId) {
|
||||
tokenService.clearToken(function () {
|
||||
cryptoService.clearKey(function () {
|
||||
userService.clearUserId(function () {
|
||||
userService.clearEmail(function () {
|
||||
siteService.clear(userId, function () {
|
||||
folderService.clear(userId, function () {
|
||||
$rootScope.vaultSites = null;
|
||||
$rootScope.vaultFolders = null;
|
||||
chrome.runtime.sendMessage({ command: 'loggedOut' });
|
||||
callback();
|
||||
cryptoService.clearKeyHash(function () {
|
||||
userService.clearUserId(function () {
|
||||
userService.clearEmail(function () {
|
||||
siteService.clear(userId, function () {
|
||||
folderService.clear(userId, function () {
|
||||
$rootScope.vaultSites = null;
|
||||
$rootScope.vaultFolders = null;
|
||||
chrome.runtime.sendMessage({ command: 'loggedOut' });
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,19 +2,42 @@
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsController', function ($scope, loginService, $state, SweetAlert, utilsService, $analytics,
|
||||
i18nService) {
|
||||
var gaKey = 'disableGa';
|
||||
|
||||
i18nService, constantsService, cryptoService) {
|
||||
utilsService.initListSectionItemListeners($(document), angular);
|
||||
$scope.disableGa = false;
|
||||
$scope.lockOption = '';
|
||||
$scope.i18n = i18nService;
|
||||
|
||||
chrome.storage.local.get(gaKey, function (obj) {
|
||||
if (obj && obj[gaKey]) {
|
||||
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
||||
if (obj && obj[constantsService.disableGaKey]) {
|
||||
$scope.disableGa = true;
|
||||
}
|
||||
else {
|
||||
$scope.disableGa = false;
|
||||
}
|
||||
});
|
||||
|
||||
chrome.storage.local.get(constantsService.lockOptionKey, function (obj) {
|
||||
if (obj && (obj[constantsService.lockOptionKey] || obj[constantsService.lockOptionKey] === 0)) {
|
||||
$scope.lockOption = obj[constantsService.lockOptionKey].toString();
|
||||
}
|
||||
else {
|
||||
$scope.lockOption = '';
|
||||
}
|
||||
});
|
||||
|
||||
$scope.changeLockOption = function () {
|
||||
var obj = {};
|
||||
obj[constantsService.lockOptionKey] = null;
|
||||
if ($scope.lockOption && $scope.lockOption !== '') {
|
||||
obj[constantsService.lockOptionKey] = parseInt($scope.lockOption);
|
||||
}
|
||||
|
||||
chrome.storage.local.set(obj, function () {
|
||||
cryptoService.toggleKey(function () { });
|
||||
});
|
||||
};
|
||||
|
||||
$scope.logOut = function () {
|
||||
SweetAlert.swal({
|
||||
title: 'Log Out',
|
||||
@@ -82,20 +105,20 @@
|
||||
}
|
||||
|
||||
$scope.updateGa = function () {
|
||||
chrome.storage.local.get(gaKey, function (obj) {
|
||||
if (obj[gaKey]) {
|
||||
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
||||
if (obj[constantsService.disableGaKey]) {
|
||||
// enable
|
||||
obj[gaKey] = false;
|
||||
obj[constantsService.disableGaKey] = false;
|
||||
}
|
||||
else {
|
||||
// disable
|
||||
$analytics.eventTrack('Disabled Google Analytics');
|
||||
obj[gaKey] = true;
|
||||
obj[constantsService.disableGaKey] = true;
|
||||
}
|
||||
|
||||
chrome.storage.local.set(obj, function () {
|
||||
$scope.disableGa = obj[gaKey];
|
||||
if (!obj[gaKey]) {
|
||||
$scope.disableGa = obj[constantsService.disableGaKey];
|
||||
if (!obj[constantsService.disableGaKey]) {
|
||||
$analytics.eventTrack('Enabled Google Analytics');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,6 +3,31 @@
|
||||
</div>
|
||||
<div class="content content-tabs">
|
||||
<div class="list">
|
||||
<div class="list-section">
|
||||
<div class="list-section-header">
|
||||
{{i18n.security}}
|
||||
</div>
|
||||
<div class="list-section-items">
|
||||
<div class="list-section-item">
|
||||
<label for="lock-option" class="item-label">{{i18n.lockOptions}}</label>
|
||||
<select id="lock-option" name="LockOption" ng-model="lockOption" ng-change="changeLockOption()">
|
||||
<option value="0">{{i18n.immediately}}</option>
|
||||
<option value="1">{{i18n.oneMinute}}</option>
|
||||
<option value="5">{{i18n.fiveMinutes}}</option>
|
||||
<option value="15">{{i18n.fifteedMinutes}}</option>
|
||||
<option value="30">{{i18n.thirtyMinutes}}</option>
|
||||
<option value="60">{{i18n.oneHour}}</option>
|
||||
<option value="240">{{i18n.fourHours}}</option>
|
||||
<option value="-1">{{i18n.onRestart}}</option>
|
||||
<option value="">{{i18n.never}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<a class="list-section-item" href="" ng-click="twoStep()">
|
||||
{{i18n.twoStepLogin}}
|
||||
<i class="fa fa-chevron-right fa-lg"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-section">
|
||||
<div class="list-section-header">
|
||||
{{i18n.account}}
|
||||
@@ -16,10 +41,6 @@
|
||||
{{i18n.changeEmail}}
|
||||
<i class="fa fa-chevron-right fa-lg"></i>
|
||||
</a>
|
||||
<a class="list-section-item" href="" ng-click="twoStep()">
|
||||
{{i18n.twoStepLogin}}
|
||||
<i class="fa fa-chevron-right fa-lg"></i>
|
||||
</a>
|
||||
<a class="list-section-item" href="" ng-click="logOut()">
|
||||
{{i18n.logOut}}
|
||||
</a>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="list-section">
|
||||
<div class="list-section-items">
|
||||
<div class="list-section-item">
|
||||
<label for="folder" class="item-label">Folder</label>
|
||||
<label for="folder" class="item-label">{{i18n.folder}}</label>
|
||||
<select id="folder" name="FolderId" ng-model="site.folderId">
|
||||
<option ng-repeat="folder in folders | orderBy: ['name']" value="{{folder.id}}">
|
||||
{{folder.name}}
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
<script src="app/tools/toolsModule.js"></script>
|
||||
<script src="app/tools/toolsController.js"></script>
|
||||
<script src="app/tools/toolsPasswordGeneratorController.js"></script>
|
||||
|
||||
<script src="app/lock/lockModule.js"></script>
|
||||
<script src="app/lock/lockController.js"></script>
|
||||
</head>
|
||||
<body ng-controller="mainController as main" class="{{main.animation}}">
|
||||
<div ui-view class="main-view"></div>
|
||||
|
||||
Reference in New Issue
Block a user