1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #486: Prompt for secret key only if updating a secret's value

This commit is contained in:
Jeremy Stretch
2016-08-18 16:43:41 -04:00
parent 6dbf2043b9
commit ab90a06c54
5 changed files with 16 additions and 11 deletions

View File

@@ -25,17 +25,20 @@ $(document).ready(function() {
});
// Adding/editing a secret
$('form.requires-private-key').submit(function(event) {
private_key_field = $('#id_private_key');
private_key_field.parents('form').submit(function(event) {
console.log("form submitted");
var private_key = sessionStorage.getItem('private_key');
if (private_key) {
$('#id_private_key').val(private_key);
} else {
private_key_field.val(private_key);
} else if ($('form .requires-private-key:first').val()) {
console.log("we need a key!");
$('#privkey_modal').modal('show');
return false;
}
});
// Prompt the user to enter a private RSA key for decryption
// Saving a private RSA key locally
$('#submit_privkey').click(function() {
var private_key = $('#user_privkey').val();
sessionStorage.setItem('private_key', private_key);