Allow users to regenerate a bot's API key.

(imported from commit 6f91c6099e305d43730c022f0d7881eed5872fa8)
This commit is contained in:
Steve Howell 2013-07-22 11:12:35 -04:00
parent df91b8c14e
commit b13efe4ee3
2 changed files with 22 additions and 1 deletions

View File

@ -178,6 +178,23 @@ $(function () {
}
});
});
$("#bots_list").on("click", "button.update_bot_api_key", function (e) {
var email = $(e.target).data('email');
$.ajax({
url: '/json/bots/' + encodeURIComponent(email) + '/api_key/regenerate',
type: 'POST',
success: function (data) {
var row = $(e.target).closest("li");
row.find(".api_key").find(".value").text(data.api_key);
row.find("api_key_error").hide();
},
error: function (xhr) {
var row = $(e.target).closest("li");
row.find(".api_key_error").text(JSON.parse(xhr.responseText).msg).show();
}
});
});
});
}());

View File

@ -10,7 +10,11 @@
</div>
<div class="api_key">
<span class="field">API Key</span>
<span class="value">{{api_key}}</e>
<span class="value">{{api_key}}</span>
<button type="submit" class="btn btn-secondary update_bot_api_key" data-email="{{email}}">
Update API Key
</button>
<div class="api_key_error text-error"></div>
</div>
<button type="submit" class="btn btn-primary delete_bot" data-email="{{email}}">
Delete Bot