feat: remove token req

This commit is contained in:
Javier Segarra 2025-04-08 14:43:13 +02:00
parent 970744c3b1
commit 011ed225a2
1 changed files with 0 additions and 31 deletions

View File

@ -18,35 +18,12 @@ module.exports = class Salix {
this._logInfo = []; this._logInfo = [];
this._salixVersion = null; this._salixVersion = null;
this._salixConfig = null; this._salixConfig = null;
this._token = null;
} }
emit() {} emit() {}
subscribe(externalListenerFunction) { subscribe(externalListenerFunction) {
this.emit = externalListenerFunction; this.emit = externalListenerFunction;
} }
async getToken() {
const { url: path, user, password } = this.conf.salix.api.login;
let response;
try {
response = await fetch(`${this.conf.salix.url}/${path}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
user,
password,
}),
});
response = await response.json();
} catch (error) {
console.error(error);
}
this.token = response.token;
}
async init(logger) { async init(logger) {
this.conf = logger.conf; this.conf = logger.conf;
const salixFileConfig = await this.loadConfig(); const salixFileConfig = await this.loadConfig();
@ -158,7 +135,6 @@ module.exports = class Salix {
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Authorization: `${this.token}`,
}, },
}; };
@ -223,13 +199,6 @@ module.exports = class Salix {
get logInfo() { get logInfo() {
return this._logInfo; return this._logInfo;
} }
get token() {
return this._token;
}
set token(token) {
this._token = token;
}
get salixVersion() { get salixVersion() {
return this._salixVersion; return this._salixVersion;
} }