@@ -488,17 +488,21 @@ angular.module('coreBOSAPIservice', [])
488488 return {
489489 'response' : function ( response ) {
490490 if ( response . config . url . indexOf ( coreBOSAPIStatus . getServiceURL ( ) ) != - 1 ) {
491- coreBOSAPIStatus . setInvalidKeys ( false ) ;
492- if ( response . config . data != undefined && response . config . data . operation == 'login' ) {
493- if ( response . data . success ) { // we have a successful login > we have to save the session
494- coreBOSAPIStatus . setSessionInfo ( {
495- _sessionid : response . data . result . sessionName ,
496- _userid : response . data . result . userId
497- } ) ;
498- } else { // unsuccessful login
491+ if ( response . data != undefined ) {
492+ if ( response . data . success ) { // we have a successful API call
493+ coreBOSAPIStatus . setInvalidKeys ( false ) ;
494+ if ( response . config . data != undefined && response . config . data . operation == 'login' ) { // we have a successful login > we have to save the session
495+ coreBOSAPIStatus . setSessionInfo ( {
496+ _sessionid : response . data . result . sessionName ,
497+ _userid : response . data . result . userId
498+ } ) ;
499+ }
500+ } else { // unsuccessful API call
499501 response . status = 401 ;
500502 response . statusText = response . data . error . code ;
501- coreBOSAPIStatus . setInvalidKeys ( true ) ;
503+ if ( response . config . data != undefined && response . config . data . operation == 'login' ) { // we have an unsuccessful login > we have to invalidate status
504+ coreBOSAPIStatus . setInvalidKeys ( true ) ;
505+ }
502506 return $q . reject ( response ) ;
503507 }
504508 }
0 commit comments