Make nice password prompts, handle enter key on modals, minor UI tweaks
This commit is contained in:
parent
57698559d9
commit
02a4f1d3fe
@ -135,7 +135,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="signaturePadCallback()">Apply</button>
|
||||
<button type="button" class="btn btn-primary btn-default" data-bs-dismiss="modal" onclick="signaturePadCallback()">Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -145,7 +145,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="signatureRemoteModalLabel"><i class="fas fa-mobile"></i> Remote Signature Pad Connection</h5>
|
||||
<h5 class="modal-title" id="signatureRemoteModalLabel"><i class="fas fa-mobile-alt"></i> Remote Signature Pad Connection</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@ -158,12 +158,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
<span id="signatureRemoteUrlLabel"></span>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<div id="signatureRemoteQRCode" class="d-flex justify-content-center p-2" style="background-color: white; border-radius: 0.5em;"></div>
|
||||
<div id="signatureRemoteQRCode" class="d-flex justify-content-center p-4" style="background-color: white; border-radius: 0.5em;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary btn-default" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -271,7 +271,22 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
<div class="modal-content">
|
||||
<div class="modal-body p-1"></div>
|
||||
<div class="modal-footer p-1">
|
||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary btn-default" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="passwordModal" tabindex="-1" aria-labelledby="passwordModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<p id="passwordModalText"></p>
|
||||
<input class="form-control" type="password" id="passwordModalInput" />
|
||||
</div>
|
||||
<div class="modal-footer p-1">
|
||||
<button type="button" class="btn btn-secondary" onclick="passwordModalCallback('');" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary btn-default" id="passwordModalSubmitBtn" onclick="passwordModalCallback($('#passwordModalInput').val());" data-bs-dismiss="modal">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -20,7 +20,7 @@ function loadKeyFromLocalStorage(callback) {
|
||||
}
|
||||
$("#lockstatus").css("display", "none");
|
||||
if (!inStorage("signingkey") || getStorage("signingkey") == "undefined") {
|
||||
var pass = prompt("Generating a new signing key (might take a while, be patient). Enter a password to protect it. You'll need to save this password somewhere safe; it cannot be recovered.");
|
||||
showPasswordPrompt("Generating a new signing key (might take a while, be patient). Enter a password to protect it. You'll need to save this password somewhere safe; it cannot be recovered.", function (pass) {
|
||||
generatePrivateKey(getStorage("notary_name") + " <null@null.com>", pass, function (key) {
|
||||
if (typeof key == "undefined") {
|
||||
callback("Could not generate key.", false);
|
||||
@ -31,8 +31,9 @@ function loadKeyFromLocalStorage(callback) {
|
||||
setStorage("signingkey", keymgr.armored_pgp_private);
|
||||
callback("Signing key generated.", true);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
var pass = prompt("Enter password to unlock signing key:");
|
||||
showPasswordPrompt("Enter password to unlock signing key:", function (pass) {
|
||||
loadPrivateKey(getStorage("signingkey"), pass, function (key) {
|
||||
if (typeof key == "undefined") {
|
||||
callback("Could not unlock key. Password is probably incorrect.", false);
|
||||
@ -42,6 +43,7 @@ function loadKeyFromLocalStorage(callback) {
|
||||
keyring.add_key_manager(keymgr);
|
||||
callback("Signing key unlocked.", true);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,9 +203,9 @@ function exportPublicKey() {
|
||||
}
|
||||
|
||||
function exportPrivateKey() {
|
||||
var pass = prompt("Enter password for private key:");
|
||||
showPasswordPrompt("Enter password for private key:", function (pass) {
|
||||
const savepriv = function (key) {
|
||||
var pass2 = prompt("Enter a password to protect the key backup:");
|
||||
showPasswordPrompt("Enter a password to protect the key backup:", function (pass2) {
|
||||
openSaveFileDialog(function (path) {
|
||||
key.export_pgp_private({
|
||||
passphrase: pass2
|
||||
@ -215,6 +217,7 @@ function exportPrivateKey() {
|
||||
}
|
||||
});
|
||||
}, "private-key.asc", ".asc");
|
||||
});
|
||||
}
|
||||
kbpgp.KeyManager.import_from_armored_pgp({
|
||||
armored: getStorage("signingkey")
|
||||
@ -238,6 +241,7 @@ function exportPrivateKey() {
|
||||
showAlert("Could not unlock key: " + err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function importPrivateKey() {
|
||||
@ -249,7 +253,7 @@ function importPrivateKey() {
|
||||
keymgr = null;
|
||||
openFileDialog(function (path) {
|
||||
var keyfile = getFileAsString(path);
|
||||
var pass = prompt("Enter password for imported key (password was set when exported):");
|
||||
showPasswordPrompt("Enter password for imported key (password was set when exported):", function (pass) {
|
||||
loadPrivateKey(keyfile, pass, function (key) {
|
||||
if (typeof key == "undefined") {
|
||||
showAlert("Could not import key. Password is probably incorrect.");
|
||||
@ -259,6 +263,7 @@ function importPrivateKey() {
|
||||
setStorage("signingkey", keymgr.armored_pgp_private);
|
||||
showAlert("Private key imported.");
|
||||
});
|
||||
});
|
||||
}, ".asc");
|
||||
}
|
||||
|
||||
|
@ -242,6 +242,25 @@ function showAlert(message) {
|
||||
new bootstrap.Modal(document.getElementById('alertModal')).show();
|
||||
}
|
||||
|
||||
var passwordModalCallback = function (pass) {};
|
||||
|
||||
function showPasswordPrompt(message, callback) {
|
||||
$("#passwordModalText").html(message);
|
||||
$("#passwordModalInput").val("");
|
||||
passwordModalCallback = callback;
|
||||
new bootstrap.Modal(document.getElementById('passwordModal')).show();
|
||||
}
|
||||
|
||||
$("#passwordModal").on("shown.bs.modal", function () {
|
||||
$("#passwordModalInput").focus();
|
||||
});
|
||||
|
||||
$(".modal").on("keydown", function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
$(this).find(".btn-default").first().click();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
setButtonSize(getStorage("button_size"));
|
||||
setAppTheme(getStorage("color_theme"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user