@@ -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