Fixes #370: Notify user when secret decryption fails

This commit is contained in:
Jeremy Stretch 2016-07-22 14:43:14 -04:00
parent b9223dda1a
commit b62cd32428
2 changed files with 15 additions and 8 deletions

View File

@ -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']);
}
}
});

View File

@ -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>