js: Fix Key.hasSecret answer

--

* The comparision result between Keyring and Keyring with secrets was
  set to the wrong Object which was not returned at all.
This commit is contained in:
Maximilian Krambach 2018-07-31 16:54:43 +02:00
parent e16a87e839
commit 9d247b7fd5
2 changed files with 7 additions and 5 deletions

View File

@ -74,7 +74,7 @@ export class GPGME_Key {
* @returns {Boolean} If the Key has a secret subkey. * @returns {Boolean} If the Key has a secret subkey.
*/ */
this.hasSecret= function (){ this.hasSecret= function (){
return this.get('hasSecret', true); return this.get('hasSecret');
}; };
/** /**

View File

@ -46,7 +46,7 @@ export class GPGME_Keyring {
* resort to a refresh() first. * resort to a refresh() first.
* @param {Boolean} search (optional) retrieve Keys from external * @param {Boolean} search (optional) retrieve Keys from external
* servers with the method(s) defined in gnupg (e.g. WKD/HKP lookup) * servers with the method(s) defined in gnupg (e.g. WKD/HKP lookup)
* @returns {Promise.<Array<GPGME_Key>|GPGME_Error>} * @returns {Promise<Array<GPGME_Key>>}
* @static * @static
* @async * @async
*/ */
@ -79,9 +79,9 @@ export class GPGME_Keyring {
}; };
} }
secondrequest().then(function(answer) { secondrequest().then(function(answer) {
for (let i=0; i < result.keys.length; i++){ for (let i=0; i < answer.keys.length; i++){
if (prepare_sync === true){ if (prepare_sync === true){
result.keys[i].hasSecret = false; result.keys[i].hasSecret = undefined;
if (answer && answer.keys) { if (answer && answer.keys) {
for (let j=0; for (let j=0;
j < answer.keys.length; j++ ){ j < answer.keys.length; j++ ){
@ -91,7 +91,9 @@ export class GPGME_Keyring {
a.fingerprint === b.fingerprint a.fingerprint === b.fingerprint
) { ) {
if (a.secret === true){ if (a.secret === true){
a.hasSecret = true; b.hasSecret = true;
} else {
b.hasSecret = false;
} }
break; break;
} }