mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -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');
|
$('#privkey_modal').modal('show');
|
||||||
} else {
|
} else {
|
||||||
unlock_secret(secret_id, private_key);
|
unlock_secret(secret_id, private_key);
|
||||||
$(this).hide();
|
|
||||||
$(this).siblings('button.lock-secret').show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Locking a secret
|
// Locking a secret
|
||||||
$('button.lock-secret').click(function (event) {
|
$('button.lock-secret').click(function (event) {
|
||||||
var secret_id = $(this).attr('secret-id');
|
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).hide();
|
||||||
$(this).siblings('button.unlock-secret').show();
|
$(this).siblings('button.unlock-secret').show();
|
||||||
});
|
});
|
||||||
@ -81,13 +82,16 @@ $(document).ready(function() {
|
|||||||
xhr.setRequestHeader("X-CSRFToken", csrf_token);
|
xhr.setRequestHeader("X-CSRFToken", csrf_token);
|
||||||
},
|
},
|
||||||
success: function (response, status) {
|
success: function (response, status) {
|
||||||
var secret_plaintext = response.plaintext;
|
$('#secret_' + secret_id).html(response.plaintext);
|
||||||
$('#secret_' + secret_id).html(secret_plaintext);
|
$('button.unlock-secret').hide();
|
||||||
return true;
|
$('button.lock-secret').show();
|
||||||
},
|
},
|
||||||
error: function (xhr, ajaxOptions, thrownError) {
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
if (xhr.status == 403) {
|
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>
|
<textarea class="form-control" id="user_privkey" style="height: 300px;"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group text-right">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user