feat: remove token req
This commit is contained in:
parent
970744c3b1
commit
011ed225a2
31
lib/salix.js
31
lib/salix.js
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue