@@ -34,47 +34,57 @@ export default class SessionMonitor {
3434 get _metadataService ( ) {
3535 return this . _userManager . metadataService ;
3636 }
37- get _client_id ( ) {
37+ get _client_id ( ) {
3838 return this . _settings . client_id ;
3939 }
40- get _checkSessionInterval ( ) {
40+ get _checkSessionInterval ( ) {
4141 return this . _settings . checkSessionInterval ;
4242 }
4343
4444 _start ( user ) {
4545 let session_state = user . session_state ;
46- Log . info ( "SessionMonitor._start; session_state:" , session_state ) ;
47-
48- if ( ! this . _checkSessionIFrame ) {
49- this . _metadataService . getCheckSessionIframe ( ) . then ( url => {
50- if ( url ) {
51- Log . info ( "Initializing check session iframe" )
52-
53- let client_id = this . _client_id ;
54- let interval = this . _checkSessionInterval ;
55-
56- this . _checkSessionIFrame = new this . _CheckSessionIFrameCtor ( this . _callback . bind ( this ) , client_id , url , interval ) ;
57- this . _checkSessionIFrame . start ( session_state ) ;
58- }
59- else {
60- Log . warn ( "No check session iframe found in the metadata" ) ;
61- }
62- } ) . catch ( err => {
63- // catch to suppress errors since we're in non-promise callback
64- Log . error ( "Error from getCheckSessionIframe:" , err . message ) ;
65- } ) ;
66- }
67- else {
68- this . _checkSessionIFrame . start ( session_state ) ;
46+
47+ if ( session_state ) {
48+ this . _sub = user . profile . sub ;
49+ Log . info ( "SessionMonitor._start; session_state:" , session_state , ", sub:" , this . _sub ) ;
50+
51+ if ( ! this . _checkSessionIFrame ) {
52+ this . _metadataService . getCheckSessionIframe ( ) . then ( url => {
53+ if ( url ) {
54+ Log . info ( "Initializing check session iframe" )
55+
56+ let client_id = this . _client_id ;
57+ let interval = this . _checkSessionInterval ;
58+
59+ this . _checkSessionIFrame = new this . _CheckSessionIFrameCtor ( this . _callback . bind ( this ) , client_id , url , interval ) ;
60+ this . _checkSessionIFrame . start ( session_state ) ;
61+ }
62+ else {
63+ Log . warn ( "No check session iframe found in the metadata" ) ;
64+ }
65+ } ) . catch ( err => {
66+ // catch to suppress errors since we're in non-promise callback
67+ Log . error ( "Error from getCheckSessionIframe:" , err . message ) ;
68+ } ) ;
69+ }
70+ else {
71+ this . _checkSessionIFrame . start ( session_state ) ;
72+ }
6973 }
7074 }
7175
7276 _stop ( ) {
7377 Log . info ( "SessionMonitor._stop" ) ;
74- this . _checkSessionIFrame . stop ( ) ;
78+
79+ this . _sub = null ;
80+
81+ if ( this . _checkSessionIFrame ) {
82+ this . _checkSessionIFrame . stop ( ) ;
83+ }
7584 }
7685
7786 _callback ( ) {
7887 Log . info ( "SessionMonitor._callback; user has changed login status" ) ;
88+ this . _userManager . events . _raiseUserSignedOut ( ) ;
7989 }
8090}
0 commit comments