Skip to content

Commit 111214b

Browse files
committed
Use correct (old)token as parameter to GET auth/logout when doing an auto-logout.
1 parent 13c6a41 commit 111214b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function ConManager(baseurl, token_name) {
130130

131131
if (resp && typeof resp === 'object' && 'httpErrorCode' in resp && resp.httpErrorCode == 401 && resp.code == 'NoUserLogon') {
132132
debug("Auth token has expired, logging in...");
133+
this._oldtoken = null;
133134
this._token = null;
134135

135136
this.login(this._username, this._password).then(() => {
@@ -427,10 +428,12 @@ function ConManager(baseurl, token_name) {
427428
debug("LOGOUT");
428429

429430
this.login_response = {};
430-
p = this.get('auth/logout', { 'token': this._token }).then((resp) => {
431+
p = this.get('auth/logout', { 'token': this._oldtoken }).then((resp) => {
432+
this._oldtoken = null;
431433
this._token = null;
432434
return resp;
433435
}).catch((e) => {
436+
this._oldtoken = null;
434437
this._token = null;
435438
return e; // failure is always an option
436439
});
@@ -452,6 +455,7 @@ function ConManager(baseurl, token_name) {
452455

453456
if (this._token_name in resp) {
454457
this._token = resp[this._token_name];
458+
this._oldtoken = resp.token;
455459

456460
debug("token %s is: %s", this._token_name, this._token);
457461
} else {
@@ -507,6 +511,7 @@ function ConManager(baseurl, token_name) {
507511
this._baseurl = url.parse(url.resolve(this._rooturl, 'api/rest/'));
508512
this._token_name = typeof token_name !== 'undefined' ? token_name : 'apiToken';
509513
this._token = null;
514+
this._oldtoken = null;
510515

511516
/**
512517
* Cached login response object.

0 commit comments

Comments
 (0)