mirror of
https://github.com/nextcloud/passman.git
synced 2024-12-26 09:34:02 +08:00
Check if field exists with hasOwnProperty
This commit is contained in:
parent
7b16bf8863
commit
48b621a378
1 changed files with 13 additions and 14 deletions
|
@ -103,26 +103,25 @@ angular.module('passmanApp')
|
|||
return _credential;
|
||||
},
|
||||
decryptSharedCredential: function (credential, sharedKey) {
|
||||
//@TODO Check permissions and skip that fields if we can't access
|
||||
var _credential = angular.copy(credential);
|
||||
var encrypted_fields = CredentialService.getEncryptedFields();
|
||||
for (var i = 0; i < encrypted_fields.length; i++) {
|
||||
var field = encrypted_fields[i];
|
||||
var fieldValue = angular.copy(_credential[field]);
|
||||
try {
|
||||
var field_decrypted_value = EncryptService.decryptString(fieldValue, sharedKey);
|
||||
} catch (e){
|
||||
console.log('Field ' + field + ' in '+ _credential.label +' could not be decrypted! Value:'+ fieldValue);
|
||||
// console.log(e);
|
||||
// throw e
|
||||
if(_credential.hasOwnProperty(field)) {
|
||||
try {
|
||||
var field_decrypted_value = EncryptService.decryptString(fieldValue, sharedKey);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw e
|
||||
}
|
||||
try {
|
||||
_credential[field] = JSON.parse(field_decrypted_value);
|
||||
} catch (e) {
|
||||
console.log('Field' + field + ' in ' + _credential.label + ' could not be parsed! Value:' + fieldValue)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
try{
|
||||
_credential[field] = JSON.parse(field_decrypted_value);
|
||||
} catch (e){
|
||||
console.log('Field' + field + ' in '+ _credential.label +' could not be parsed! Value:'+ fieldValue)
|
||||
// throw e
|
||||
}
|
||||
|
||||
}
|
||||
return _credential;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue