mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-07 20:16:16 +08:00
Catch some errors
This commit is contained in:
parent
db819771d8
commit
713013caa7
3 changed files with 43 additions and 35 deletions
|
@ -358,7 +358,7 @@ class ShareController extends ApiController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DoesNotExistException $ex){
|
catch (DoesNotExistException $ex){
|
||||||
return new NotFoundResponse();
|
return new JSONResponse(array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,13 @@ angular.module('passmanApp')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var storedCredential = SettingsService.getSetting('share_credential');
|
var storedCredential = SettingsService.getSetting('share_credential');
|
||||||
if (!storedCredential) {
|
|
||||||
|
if(!storedCredential) {
|
||||||
$location.path('/vault/' + $routeParams.vault_id);
|
$location.path('/vault/' + $routeParams.vault_id);
|
||||||
} else {
|
} else {
|
||||||
$scope.storedCredential = CredentialService.decryptCredential(angular.copy(storedCredential));
|
$scope.storedCredential = CredentialService.decryptCredential(angular.copy(storedCredential));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.active_vault) {
|
if ($scope.active_vault) {
|
||||||
$scope.$parent.selectedVault = true;
|
$scope.$parent.selectedVault = true;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +92,9 @@ angular.module('passmanApp')
|
||||||
|
|
||||||
|
|
||||||
ShareService.getSharedCredentialACL($scope.storedCredential).then(function (aclList) {
|
ShareService.getSharedCredentialACL($scope.storedCredential).then(function (aclList) {
|
||||||
var enc_key = EncryptService.decryptString(angular.copy($scope.storedCredential.shared_key));
|
|
||||||
|
var enc_key = ($scope.storedCredential.shared_key) ? EncryptService.decryptString(angular.copy($scope.storedCredential.shared_key)) : false;
|
||||||
|
|
||||||
for(var i = 0; i < aclList.length; i++){
|
for(var i = 0; i < aclList.length; i++){
|
||||||
var acl = aclList[i];
|
var acl = aclList[i];
|
||||||
if(acl.user_id === null){
|
if(acl.user_id === null){
|
||||||
|
@ -102,8 +106,10 @@ angular.module('passmanApp')
|
||||||
acl: new SharingACL(acl.permissions)
|
acl: new SharingACL(acl.permissions)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var hash = window.btoa($scope.storedCredential.guid + '<::>'+ enc_key)
|
if(enc_key) {
|
||||||
$scope.share_link = $location.$$protocol + '://' + $location.$$host + OC.generateUrl('apps/passman/share/public#') + hash;
|
var hash = window.btoa($scope.storedCredential.guid + '<::>' + enc_key)
|
||||||
|
$scope.share_link = $location.$$protocol + '://' + $location.$$host + OC.generateUrl('apps/passman/share/public#') + hash;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var obj = {
|
var obj = {
|
||||||
userId: acl.user_id,
|
userId: acl.user_id,
|
||||||
|
@ -163,16 +169,16 @@ angular.module('passmanApp')
|
||||||
NotificationService.showNotification('Credential unshared', 4000)
|
NotificationService.showNotification('Credential unshared', 4000)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
console.log($scope.storedCredential);
|
|
||||||
$scope.applyShare = function () {
|
$scope.applyShare = function () {
|
||||||
$scope.share_settings.cypher_progress.percent = 0;
|
$scope.share_settings.cypher_progress.percent = 0;
|
||||||
$scope.share_settings.cypher_progress.done = 0;
|
$scope.share_settings.cypher_progress.done = 0;
|
||||||
$scope.share_settings.cypher_progress.total = 0;
|
$scope.share_settings.cypher_progress.total = 0;
|
||||||
$scope.share_settings.cypher_progress.times = [];
|
$scope.share_settings.cypher_progress.times = [];
|
||||||
$scope.share_settings.cypher_progress.times_total = [];
|
$scope.share_settings.cypher_progress.times_total = [];
|
||||||
|
console.log($scope.storedCredential);
|
||||||
//Credential is already shared
|
//Credential is already shared
|
||||||
if($scope.storedCredential.shared_key !== null){
|
if($scope.storedCredential.shared_key && $scope.storedCredential.shared_key != '' && $scope.storedCredential.shared_key != null){
|
||||||
console.log('Shared key found');
|
console.log('Shared key found');
|
||||||
if($scope.share_settings.linkSharing.enabled){
|
if($scope.share_settings.linkSharing.enabled){
|
||||||
var expire_time = new Date(angular.copy( $scope.share_settings.linkSharing.settings.expire_time)).getTime()/1000;
|
var expire_time = new Date(angular.copy( $scope.share_settings.linkSharing.settings.expire_time)).getTime()/1000;
|
||||||
|
@ -225,7 +231,7 @@ angular.module('passmanApp')
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
crypt(iterator);
|
crypt(iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,29 +248,33 @@ angular.module('passmanApp')
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
var iterator = i; // Keeps it available inside the promises callback
|
var iterator = i; // Keeps it available inside the promises callback
|
||||||
if (list[i].type == "user") {
|
if (list[i].type == "user") {
|
||||||
ShareService.getVaultsByUser(list[i].userId).then(function (data) {
|
var crypt = function (iterator) {
|
||||||
$scope.share_settings.cypher_progress.total += data.length;
|
ShareService.getVaultsByUser(list[i].userId).then(function (data) {
|
||||||
list[iterator].vaults = data;
|
$scope.share_settings.cypher_progress.total += data.length;
|
||||||
var start = new Date().getTime() / 1000;
|
|
||||||
console.log('Begin messing with permissions');
|
list[iterator].vaults = data;
|
||||||
ShareService.cypherRSAStringWithPublicKeyBulkAsync(list[iterator].vaults, key)
|
var start = new Date().getTime() / 1000;
|
||||||
.progress(function (data) {
|
console.log('Begin messing with permissions');
|
||||||
$scope.share_settings.cypher_progress.done++;
|
ShareService.cypherRSAStringWithPublicKeyBulkAsync(list[iterator].vaults, enc_key)
|
||||||
$scope.share_settings.cypher_progress.percent = $scope.share_settings.cypher_progress.done / $scope.share_settings.cypher_progress.total * 100;
|
.progress(function (data) {
|
||||||
$scope.$digest();
|
$scope.share_settings.cypher_progress.done++;
|
||||||
})
|
$scope.share_settings.cypher_progress.percent = $scope.share_settings.cypher_progress.done / $scope.share_settings.cypher_progress.total * 100;
|
||||||
.then(function (result) {
|
$scope.$digest();
|
||||||
console.log("Took: " + ((new Date().getTime() / 1000) - start) + "s to cypher the string for user [" + data[0].user_id + "]");
|
})
|
||||||
$scope.share_settings.cypher_progress.times.push({
|
.then(function (result) {
|
||||||
time: ((new Date().getTime() / 1000) - start),
|
console.log("Took: " + ((new Date().getTime() / 1000) - start) + "s to cypher the string for user [" + data[0].user_id + "]");
|
||||||
user: data[0].user_id
|
$scope.share_settings.cypher_progress.times.push({
|
||||||
|
time: ((new Date().getTime() / 1000) - start),
|
||||||
|
user: data[0].user_id
|
||||||
|
});
|
||||||
|
list[iterator].vaults = result;
|
||||||
|
console.log(list[iterator])
|
||||||
|
$scope.uploadChanges(list[iterator]);
|
||||||
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
list[iterator].vaults = result;
|
});
|
||||||
console.log(list[iterator])
|
};
|
||||||
$scope.uploadChanges(list[iterator]);
|
crypt(iterator);
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,7 @@ angular.module('passmanApp')
|
||||||
var fieldValue = angular.copy(credential[field]);
|
var fieldValue = angular.copy(credential[field]);
|
||||||
_credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue));
|
_credential[field] = EncryptService.encryptString(JSON.stringify(fieldValue));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log('Skipping encryption')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_credential.expire_time = new Date( angular.copy(credential.expire_time) ).getTime() / 1000;
|
_credential.expire_time = new Date( angular.copy(credential.expire_time) ).getTime() / 1000;
|
||||||
|
|
||||||
var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + credential.credential_id);
|
var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + credential.credential_id);
|
||||||
|
@ -115,6 +112,7 @@ angular.module('passmanApp')
|
||||||
for (var i = 0; i < _encryptedFields.length; i++) {
|
for (var i = 0; i < _encryptedFields.length; i++) {
|
||||||
var field = _encryptedFields[i];
|
var field = _encryptedFields[i];
|
||||||
var fieldValue = angular.copy(credential[field]);
|
var fieldValue = angular.copy(credential[field]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var field_decrypted_value = EncryptService.decryptString(fieldValue)
|
var field_decrypted_value = EncryptService.decryptString(fieldValue)
|
||||||
} catch (e){
|
} catch (e){
|
||||||
|
@ -125,7 +123,7 @@ angular.module('passmanApp')
|
||||||
credential[field] = JSON.parse(field_decrypted_value);
|
credential[field] = JSON.parse(field_decrypted_value);
|
||||||
} catch (e){
|
} catch (e){
|
||||||
console.log('Field' + field + ' in '+ credential.label +' could not be parsed! Value:'+ fieldValue)
|
console.log('Field' + field + ' in '+ credential.label +' could not be parsed! Value:'+ fieldValue)
|
||||||
throw e
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue