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._salixVersion = null;
|
||||
this._salixConfig = null;
|
||||
this._token = null;
|
||||
}
|
||||
emit() {}
|
||||
subscribe(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) {
|
||||
this.conf = logger.conf;
|
||||
const salixFileConfig = await this.loadConfig();
|
||||
|
@ -158,7 +135,6 @@ module.exports = class Salix {
|
|||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `${this.token}`,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -223,13 +199,6 @@ module.exports = class Salix {
|
|||
get logInfo() {
|
||||
return this._logInfo;
|
||||
}
|
||||
|
||||
get token() {
|
||||
return this._token;
|
||||
}
|
||||
set token(token) {
|
||||
this._token = token;
|
||||
}
|
||||
get salixVersion() {
|
||||
return this._salixVersion;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue