mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Also allow backup PGP keys on server on import #89
This commit is contained in:
parent
83aa65981b
commit
43cbbd51c1
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ trait Pgp
|
|||
return $this->DefaultResponse($GPG ? $GPG->deleteKey($sKeyId, $bPrivate) : false);
|
||||
}
|
||||
|
||||
public function DoGnupgImportKey() : array
|
||||
public function DoPgpImportKey() : array
|
||||
{
|
||||
$sKey = $this->GetActionParam('key', '');
|
||||
$sKeyId = $this->GetActionParam('keyId', '');
|
||||
|
@ -217,8 +217,17 @@ trait Pgp
|
|||
}
|
||||
}
|
||||
|
||||
$GPG = $sKey ? $this->GnuPG() : null;
|
||||
return $this->DefaultResponse($GPG ? $GPG->import($sKey) : false);
|
||||
$result = false;
|
||||
if ($sKey) {
|
||||
if ($this->GetActionParam('backup', '')) {
|
||||
$result = $result || Backup::PGPKey($sKey);
|
||||
}
|
||||
if ($this->GetActionParam('gnuPG', '') && ($GPG = $this->GnuPG())) {
|
||||
$result = $result || $GPG->import($sKey);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->DefaultResponse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<textarea class="input-xxlarge" rows="14" autofocus="" autocomplete="off" data-bind="value: key" required=""></textarea>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<!--
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
|
@ -22,7 +21,6 @@
|
|||
}
|
||||
}"></div>
|
||||
<br>
|
||||
-->
|
||||
<div data-bind="visible: canGnuPG, component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
|
|
Loading…
Reference in a new issue