diff --git a/src/bot.manager.widget.js b/src/bot.manager.widget.js index c80bb13..d339d7f 100644 --- a/src/bot.manager.widget.js +++ b/src/bot.manager.widget.js @@ -52,8 +52,13 @@ class BotManagerWidget extends LitElement { if (!endpoint) { return; } + const accessToken = localStorage.getItem("access_token"); - fetch(endpoint + "/models/") + fetch(endpoint + "/models/", { + headers: { + "Authorization": `Bearer ${accessToken}` + } + }) .then((response) => { if ( response.ok && diff --git a/src/model-training.js b/src/model-training.js index 14cd693..5ade7ac 100644 --- a/src/model-training.js +++ b/src/model-training.js @@ -309,6 +309,9 @@ class ModelTraining extends LitElement { markdownTrainingData: _this.editor.getText(), }), contentType: "application/json", + headers: { + "Authorization": "Bearer " + localStorage.getItem("access_token"), + }, success: function (data, textStatus, jqXHR) { $(_this.htmlQuery("#trainingStatus")).text(data); }, @@ -413,6 +416,9 @@ class ModelTraining extends LitElement { type: "GET", url: trainingStatusUrl, contentType: "text/plain", + headers: { + "Authorization": "Bearer " + localStorage.getItem("access_token"), + }, success: function (data, textStatus, jqXHR) { $(_this.htmlQuery("#trainingStatus")).text(data); }, @@ -435,6 +441,9 @@ class ModelTraining extends LitElement { $.ajax({ type: "POST", url: trainingStatusUrl + name, + headers: { + "Authorization": "Bearer " + localStorage.getItem("access_token"), + }, data: trainingData, contentType: "text/plain", success: function (data, textStatus, jqXHR) { @@ -460,6 +469,9 @@ class ModelTraining extends LitElement { type: "GET", url: trainingStatusUrl + name, contentType: "text/plain", + headers: { + "Authorization": "Bearer " + localStorage.getItem("access_token"), + }, success: function (data, textStatus, jqXHR) { $(_this.htmlQuery("#trainingStatus")).text("Data loaded."); _this.editor.setText(data); @@ -480,6 +492,9 @@ class ModelTraining extends LitElement { type: "GET", url: trainingStatusUrl + "/training/", contentType: "application/json", + headers: { + "Authorization": "Bearer " + localStorage.getItem("access_token"), + }, success: function (data, textStatus, jqXHR) { if (textStatus !== "success") { return;