Fixed API key reset after reconnect

This commit is contained in:
Gina Häußge 2015-10-01 16:03:16 +02:00
parent 085ab77c57
commit 6a11f4a4d8

View file

@ -14,12 +14,13 @@ $(function() {
OctoPrint.options.apikey = UI_API_KEY;
OctoPrint.socket.onMessage("connected", function(data) {
OctoPrint.options.apikey = data.apikey;
var payload = data.data;
OctoPrint.options.apikey = payload.apikey;
// update the API key directly in jquery's ajax options too,
// to ensure the fileupload plugin and any plugins still using
// $.ajax directly still work fine too
UI_API_KEY = data["apikey"];
UI_API_KEY = payload["apikey"];
$.ajaxSetup({
headers: {"X-Api-Key": UI_API_KEY}
});