@@ -130,6 +130,7 @@ function ConManager(baseurl, token_name) {
130
130
131
131
if ( resp && typeof resp === 'object' && 'httpErrorCode' in resp && resp . httpErrorCode == 401 && resp . code == 'NoUserLogon' ) {
132
132
debug ( "Auth token has expired, logging in..." ) ;
133
+ this . _oldtoken = null ;
133
134
this . _token = null ;
134
135
135
136
this . login ( this . _username , this . _password ) . then ( ( ) => {
@@ -427,10 +428,12 @@ function ConManager(baseurl, token_name) {
427
428
debug ( "LOGOUT" ) ;
428
429
429
430
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 ;
431
433
this . _token = null ;
432
434
return resp ;
433
435
} ) . catch ( ( e ) => {
436
+ this . _oldtoken = null ;
434
437
this . _token = null ;
435
438
return e ; // failure is always an option
436
439
} ) ;
@@ -452,6 +455,7 @@ function ConManager(baseurl, token_name) {
452
455
453
456
if ( this . _token_name in resp ) {
454
457
this . _token = resp [ this . _token_name ] ;
458
+ this . _oldtoken = resp . token ;
455
459
456
460
debug ( "token %s is: %s" , this . _token_name , this . _token ) ;
457
461
} else {
@@ -507,6 +511,7 @@ function ConManager(baseurl, token_name) {
507
511
this . _baseurl = url . parse ( url . resolve ( this . _rooturl , 'api/rest/' ) ) ;
508
512
this . _token_name = typeof token_name !== 'undefined' ? token_name : 'apiToken' ;
509
513
this . _token = null ;
514
+ this . _oldtoken = null ;
510
515
511
516
/**
512
517
* Cached login response object.
0 commit comments