@@ -30,14 +30,14 @@ const authSetup = function () {
3030 const v3JWTCookie = 'v3jwt' ;
3131 const tcJWTCookie = 'tcjwt' ;
3232 const tcSSOCookie = 'tcsso' ;
33- const cookieExpireIn = 12 * 60 ; // 12 hrs
33+ const cookieExpireIn = 12 * 60 ; // 12 hrs
3434 const refreshTokenInterval = 60000 ; // in milliseconds
3535 const refreshTokenOffset = 65 ; // in seconds
3636 const returnAppUrl = qs [ 'retUrl' ] ;
3737 const shouldLogout = qs [ 'logout' ] ;
3838 const regSource = qs [ 'regSource' ] ;
39- const utmSource = qs [ 'utm_source' ] ;
40-
39+ const utmSource = qs [ 'utm_source' ] ;
40+
4141
4242 var auth0 = null ;
4343 var isAuthenticated = false ;
@@ -56,6 +56,7 @@ const authSetup = function () {
5656 : 'memory' ,
5757 useRefreshTokens : useRefreshTokens
5858 } ) . then ( _init ) ;
59+ window . addEventListener ( "message" , receiveMessage , false ) ;
5960 } ;
6061
6162 const _init = function ( authObj ) {
@@ -93,7 +94,7 @@ const authSetup = function () {
9394 } ) . catch ( function ( e ) {
9495 console . log ( "Error in refreshing token: " , e )
9596 if ( e . error && ( ( e . error == "login_required" ) || ( e . error == "timeout" ) ) ) {
96- clearInterval ( callRefreshTokenFun ) ;
97+ clearInterval ( callRefreshTokenFun ) ;
9798 }
9899 }
99100 ) ;
@@ -284,19 +285,26 @@ const authSetup = function () {
284285 const pattern = '#!/member' ;
285286 const sso_pattern = '/#!/sso-login' ;
286287 const logout_pattern = '/#!/logout?' ;
287-
288- if ( window . location . href . indexOf ( pattern ) > - 1 ) {
289- window . location . href = window . location . href . replace ( pattern , '' ) ;
288+
289+ if ( window . location . href . indexOf ( pattern ) > - 1 ) {
290+ window . location . href = window . location . href . replace ( pattern , '' ) ;
290291 }
291292
292- if ( window . location . href . indexOf ( sso_pattern ) > - 1 ) {
293+ if ( window . location . href . indexOf ( sso_pattern ) > - 1 ) {
293294 window . location . href = window . location . href . replace ( sso_pattern , '' ) ;
294295 }
295296
296- if ( window . location . href . indexOf ( logout_pattern ) > - 1 ) {
297+ if ( window . location . href . indexOf ( logout_pattern ) > - 1 ) {
297298 window . location . href = window . location . href . replace ( logout_pattern , '/?logout=true&' ) ;
298299 }
299300 }
300301
302+ /**
303+ * will receive message from iframe
304+ */
305+ function receiveMessage ( e ) {
306+ console . log ( "received Event:" , e ) ;
307+ }
308+
301309 init ( ) ;
302310} ;
0 commit comments