mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Fixes #370: Notify user when secret decryption fails
This commit is contained in:
parent
b9223dda1a
commit
b62cd32428
@ -10,15 +10,16 @@ $(document).ready(function() {
|
||||
$('#privkey_modal').modal('show');
|
||||
} else {
|
||||
unlock_secret(secret_id, private_key);
|
||||
$(this).hide();
|
||||
$(this).siblings('button.lock-secret').show();
|
||||
}
|
||||
});
|
||||
|
||||
// Locking a secret
|
||||
$('button.lock-secret').click(function (event) {
|
||||
var secret_id = $(this).attr('secret-id');
|
||||
$('#secret_' + secret_id).html('********');
|
||||
var secret_div = $('#secret_' + secret_id);
|
||||
|
||||
// Delete the plaintext
|
||||
secret_div.html('********');
|
||||
$(this).hide();
|
||||
$(this).siblings('button.unlock-secret').show();
|
||||
});
|
||||
@ -81,13 +82,16 @@ $(document).ready(function() {
|
||||
xhr.setRequestHeader("X-CSRFToken", csrf_token);
|
||||
},
|
||||
success: function (response, status) {
|
||||
var secret_plaintext = response.plaintext;
|
||||
$('#secret_' + secret_id).html(secret_plaintext);
|
||||
return true;
|
||||
$('#secret_' + secret_id).html(response.plaintext);
|
||||
$('button.unlock-secret').hide();
|
||||
$('button.lock-secret').show();
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
if (xhr.status == 403) {
|
||||
alert("Decryption failed: " + xhr.statusText);
|
||||
alert("Permission denied");
|
||||
} else {
|
||||
var json = jQuery.parseJSON(xhr.responseText);
|
||||
alert("Decryption failed: " + json['error']);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -17,7 +17,10 @@
|
||||
<textarea class="form-control" id="user_privkey" style="height: 300px;"></textarea>
|
||||
</div>
|
||||
<div class="form-group text-right">
|
||||
<button id="submit_privkey" class="btn btn-primary unlock-secret" data-dismiss="modal">Submit RSA Key</button>
|
||||
<button id="submit_privkey" class="btn btn-primary unlock-secret" data-dismiss="modal">
|
||||
<i class="fa fa-save" aria-hidden="True"></i>
|
||||
Save RSA Key
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user