Also allow backup PGP keys on server on import #89

This commit is contained in:
the-djmaze 2024-02-08 18:01:15 +01:00
parent 83aa65981b
commit 43cbbd51c1
4 changed files with 29 additions and 22 deletions

View file

@ -117,19 +117,6 @@ export const GnuPGUserStore = new class {
return SettingsCapa('GnuPG');
}
importKey(key, callback) {
Remote.request('GnupgImportKey',
(iError, oData) => {
if (oData?.Result/* && (oData.Result.imported || oData.Result.secretimported)*/) {
this.loadKeyrings();
}
callback?.(iError, oData);
}, {
key: key
}
);
}
/**
keyPair.privateKey
keyPair.publicKey

View file

@ -19,7 +19,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
keyErrorMessage: '',
saveGnuPG: true,
saveServer: false
saveServer: true
});
this.canGnuPG = GnuPGUserStore.isSupported();
@ -69,9 +69,22 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
match = reg.exec(keyTrimmed);
if (match && 0 < count) {
if (match[0] && match[1] && match[2] && match[1] === match[2]) {
this.saveGnuPG() && GnuPGUserStore.isSupported() && GnuPGUserStore.importKey(this.key(), (iError, oData) => {
iError && alert(oData.ErrorMessage);
});
const GnuPG = this.saveGnuPG() && GnuPGUserStore.isSupported(),
backup = this.saveServer();
if (GnuPG || backup()) {
Remote.request('PgpImportKey',
(iError, oData) => {
if (GnuPG && oData?.Result/* && (oData.Result.imported || oData.Result.secretimported)*/) {
GnuPGUserStore.loadKeyrings();
}
iError && alert(oData.ErrorMessage);
}, {
key: this.key(),
gnuPG: GnuPG,
backup: backup
}
);
}
OpenPGPUserStore.isSupported() && OpenPGPUserStore.importKey(this.key());
}