mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Also allow backup PGP keys on server on import #89
This commit is contained in:
parent
83aa65981b
commit
43cbbd51c1
4 changed files with 29 additions and 22 deletions
|
|
@ -117,19 +117,6 @@ export const GnuPGUserStore = new class {
|
||||||
return SettingsCapa('GnuPG');
|
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.privateKey
|
||||||
keyPair.publicKey
|
keyPair.publicKey
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
keyErrorMessage: '',
|
keyErrorMessage: '',
|
||||||
|
|
||||||
saveGnuPG: true,
|
saveGnuPG: true,
|
||||||
saveServer: false
|
saveServer: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.canGnuPG = GnuPGUserStore.isSupported();
|
this.canGnuPG = GnuPGUserStore.isSupported();
|
||||||
|
|
@ -69,9 +69,22 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
match = reg.exec(keyTrimmed);
|
match = reg.exec(keyTrimmed);
|
||||||
if (match && 0 < count) {
|
if (match && 0 < count) {
|
||||||
if (match[0] && match[1] && match[2] && match[1] === match[2]) {
|
if (match[0] && match[1] && match[2] && match[1] === match[2]) {
|
||||||
this.saveGnuPG() && GnuPGUserStore.isSupported() && GnuPGUserStore.importKey(this.key(), (iError, oData) => {
|
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);
|
iError && alert(oData.ErrorMessage);
|
||||||
});
|
}, {
|
||||||
|
key: this.key(),
|
||||||
|
gnuPG: GnuPG,
|
||||||
|
backup: backup
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
OpenPGPUserStore.isSupported() && OpenPGPUserStore.importKey(this.key());
|
OpenPGPUserStore.isSupported() && OpenPGPUserStore.importKey(this.key());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ trait Pgp
|
||||||
return $this->DefaultResponse($GPG ? $GPG->deleteKey($sKeyId, $bPrivate) : false);
|
return $this->DefaultResponse($GPG ? $GPG->deleteKey($sKeyId, $bPrivate) : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DoGnupgImportKey() : array
|
public function DoPgpImportKey() : array
|
||||||
{
|
{
|
||||||
$sKey = $this->GetActionParam('key', '');
|
$sKey = $this->GetActionParam('key', '');
|
||||||
$sKeyId = $this->GetActionParam('keyId', '');
|
$sKeyId = $this->GetActionParam('keyId', '');
|
||||||
|
|
@ -217,8 +217,17 @@ trait Pgp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$GPG = $sKey ? $this->GnuPG() : null;
|
$result = false;
|
||||||
return $this->DefaultResponse($GPG ? $GPG->import($sKey) : 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>
|
<textarea class="input-xxlarge" rows="14" autofocus="" autocomplete="off" data-bind="value: key" required=""></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<!--
|
|
||||||
<div data-bind="component: {
|
<div data-bind="component: {
|
||||||
name: 'Checkbox',
|
name: 'Checkbox',
|
||||||
params: {
|
params: {
|
||||||
|
|
@ -22,7 +21,6 @@
|
||||||
}
|
}
|
||||||
}"></div>
|
}"></div>
|
||||||
<br>
|
<br>
|
||||||
-->
|
|
||||||
<div data-bind="visible: canGnuPG, component: {
|
<div data-bind="visible: canGnuPG, component: {
|
||||||
name: 'Checkbox',
|
name: 'Checkbox',
|
||||||
params: {
|
params: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue