mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-09 19:13:03 +00:00
support revoking tokens from token page
This commit is contained in:
@@ -132,9 +132,9 @@ define(['jquery', 'utils'], function ($, utils) {
|
||||
);
|
||||
};
|
||||
|
||||
JHAPI.prototype.delete_token = function (user, token_id, options) {
|
||||
JHAPI.prototype.revoke_token = function (user, token_id, options) {
|
||||
options = options || {};
|
||||
options = update(options, {type: 'POST'});
|
||||
options = update(options, {type: 'DELETE'});
|
||||
this.api_request(
|
||||
utils.url_path_join('users', user, 'tokens', token_id),
|
||||
options
|
||||
|
@@ -32,5 +32,22 @@ require(["jquery", "jhapi", "moment"], function($, JHAPI, moment) {
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
function get_token_row(element) {
|
||||
while (!element.hasClass("token-row")) {
|
||||
element = element.parent();
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
$(".revoke-token-btn").click(function() {
|
||||
var el = $(this);
|
||||
var row = get_token_row(el);
|
||||
el.attr("disabled", true);
|
||||
api.revoke_token(user, row.data('token-id'), {
|
||||
success: function(reply) {
|
||||
row.remove();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -71,7 +71,7 @@
|
||||
{{ token.created.isoformat() + 'Z' }}
|
||||
</td>
|
||||
<td class="col-sm-1 text-center">
|
||||
<a role="button" class="delete-token-btn btn btn-xs btn-danger">revoke</a>
|
||||
<a role="button" class="revoke-token-btn btn btn-xs btn-danger">revoke</a>
|
||||
</td>
|
||||
{% endblock token_row %}
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user