mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-31 08:20:37 +01:00
Switch vault listing to user ciphers apis instead of calling login and folder separately
This commit is contained in:
parent
cf144aa2c1
commit
ccc527f329
@ -52,7 +52,7 @@ angular
|
||||
_service.logOut = function () {
|
||||
tokenService.clearToken();
|
||||
tokenService.clearRefreshToken();
|
||||
cryptoService.clearKey();
|
||||
cryptoService.clearKeys();
|
||||
_userProfile = null;
|
||||
};
|
||||
|
||||
|
@ -5,57 +5,48 @@
|
||||
$scope.logins = [];
|
||||
$scope.folders = [];
|
||||
|
||||
$scope.loadingLogins = true;
|
||||
apiService.logins.list({}, function (logins) {
|
||||
$scope.loadingLogins = false;
|
||||
$scope.loading = true;
|
||||
apiService.ciphers.list({}, function (ciphers) {
|
||||
$scope.loading = false;
|
||||
|
||||
var decLogins = [];
|
||||
for (var i = 0; i < logins.Data.length; i++) {
|
||||
var decLogin = {
|
||||
id: logins.Data[i].Id,
|
||||
folderId: logins.Data[i].FolderId,
|
||||
favorite: logins.Data[i].Favorite
|
||||
};
|
||||
|
||||
try { decLogin.name = cryptoService.decrypt(logins.Data[i].Name); }
|
||||
catch (err) { decLogin.name = '[error: cannot decrypt]'; }
|
||||
|
||||
if (logins.Data[i].Username) {
|
||||
try { decLogin.username = cryptoService.decrypt(logins.Data[i].Username); }
|
||||
catch (err) { decLogin.username = '[error: cannot decrypt]'; }
|
||||
}
|
||||
|
||||
decLogins.push(decLogin);
|
||||
}
|
||||
|
||||
$scope.logins = decLogins;
|
||||
}, function () {
|
||||
$scope.loadingLogins = false;
|
||||
});
|
||||
|
||||
$scope.loadingFolders = true;
|
||||
apiService.folders.list({}, function (folders) {
|
||||
$scope.loadingFolders = false;
|
||||
|
||||
var decFolders = [{
|
||||
id: null,
|
||||
name: '(none)'
|
||||
}];
|
||||
|
||||
for (var i = 0; i < folders.Data.length; i++) {
|
||||
var decFolder = {
|
||||
id: folders.Data[i].Id
|
||||
};
|
||||
for (var i = 0; i < ciphers.Data.length; i++) {
|
||||
if (ciphers.Data[i].Type === 0) {
|
||||
var decFolder = {
|
||||
id: ciphers.Data[i].Id
|
||||
};
|
||||
|
||||
try { decFolder.name = cryptoService.decrypt(folders.Data[i].Name); }
|
||||
catch (err) { decFolder.name = '[error: cannot decrypt]'; }
|
||||
try { decFolder.name = cryptoService.decrypt(ciphers.Data[i].Data.Name); }
|
||||
catch (err) { decFolder.name = '[error: cannot decrypt]'; }
|
||||
|
||||
decFolders.push(decFolder);
|
||||
decFolders.push(decFolder);
|
||||
}
|
||||
else {
|
||||
var decLogin = {
|
||||
id: ciphers.Data[i].Id,
|
||||
folderId: ciphers.Data[i].FolderId,
|
||||
favorite: ciphers.Data[i].Favorite
|
||||
};
|
||||
|
||||
try { decLogin.name = cryptoService.decrypt(ciphers.Data[i].Data.Name); }
|
||||
catch (err) { decLogin.name = '[error: cannot decrypt]'; }
|
||||
|
||||
if (ciphers.Data[i].Data.Username) {
|
||||
try { decLogin.username = cryptoService.decrypt(ciphers.Data[i].Data.Username); }
|
||||
catch (err) { decLogin.username = '[error: cannot decrypt]'; }
|
||||
}
|
||||
|
||||
decLogins.push(decLogin);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.folders = decFolders;
|
||||
}, function () {
|
||||
$scope.loadingFolders = false;
|
||||
$scope.logins = decLogins;
|
||||
});
|
||||
|
||||
$scope.folderSort = function (item) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
</h1>
|
||||
</section>
|
||||
<section class="content">
|
||||
<div ng-show="loadingFolders && !folders.length">
|
||||
<div ng-show="loading && !folders.length">
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
<div class="box" ng-repeat="folder in folders | orderBy: folderSort" ng-show="folders.length && (!main.searchVaultText || folderLogins.length)">
|
||||
@ -27,10 +27,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body" ng-class="{'no-padding': folderLogins.length}">
|
||||
<div ng-show="loadingLogins && !folderLogins.length">
|
||||
<p>Loading logins...</p>
|
||||
</div>
|
||||
<div ng-show="!loadingLogins && !folderLogins.length">
|
||||
<div ng-show="!folderLogins.length">
|
||||
<p>No logins in this folder.</p>
|
||||
<button type="button" ng-click="addLogin(folder)" class="btn btn-default btn-flat">Add a Login</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user