@@ -263,60 +263,73 @@ const authSetup = function () {
263263 }
264264
265265 const storeToken = function ( ) {
266- auth0 . getUser ( ) . then ( function ( user ) {
267- auth0 . getIdTokenClaims ( ) . then ( function ( claims ) {
268- logger ( "claims..." , claims ) ;
269- idToken = claims . __raw ;
270- let userActive = false ;
266+ auth0 . getIdTokenClaims ( ) . then ( function ( claims ) {
267+ idToken = claims . __raw ;
268+
269+ logger . info ( 'Claims' , JSON . stringify ( claims ) ) ;
270+
271+ let showOnboardingWizard = false ;
272+ Object . keys ( claims ) . forEach ( key => {
273+ logger . info ( 'Checking key' , key ) ;
274+ if ( key . indexOf ( 'show_onboarding_wizard' ) !== - 1 ) {
275+ if ( claims [ key ] ) {
276+ showOnboardingWizard = true ;
277+ }
278+ }
279+ } ) ;
280+
281+ logger . info ( 'Show Onboarding Wizard' , showOnboardingWizard ) ;
282+
283+ let userActive = false ;
284+ Object . keys ( claims ) . findIndex ( function ( key ) {
285+ if ( key . includes ( 'active' ) ) {
286+ userActive = claims [ key ] ;
287+ return true ;
288+ }
289+ return false ;
290+ } ) ;
291+ if ( userActive ) {
292+ let tcsso = '' ;
271293 Object . keys ( claims ) . findIndex ( function ( key ) {
272- if ( key . includes ( 'active' ) ) {
273- userActive = claims [ key ] ;
294+ if ( key . includes ( tcSSOCookie ) ) {
295+ tcsso = claims [ key ] ;
274296 return true ;
275297 }
276298 return false ;
277299 } ) ;
278- if ( userActive ) {
279- let tcsso = '' ;
280- Object . keys ( claims ) . findIndex ( function ( key ) {
281- if ( key . includes ( tcSSOCookie ) ) {
282- tcsso = claims [ key ] ;
283- return true ;
284- }
285- return false ;
286- } ) ;
287- logger ( 'Storing token...' , true ) ;
288- try {
289- const exT = getCookieExpiry ( idToken ) ;
290- if ( exT ) {
291- setDomainCookie ( tcJWTCookie , idToken , exT ) ;
292- setDomainCookie ( v3JWTCookie , idToken , exT ) ;
293- setDomainCookie ( tcSSOCookie , tcsso , exT ) ;
294- } else {
295- setCookie ( tcJWTCookie , idToken , cookieExpireIn ) ;
296- setCookie ( v3JWTCookie , idToken , cookieExpireIn ) ;
297- setCookie ( tcSSOCookie , tcsso , cookieExpireIn ) ;
298- }
299- } catch ( e ) {
300- logger ( 'Error occured in fecthing token expiry time' , e . message ) ;
300+ logger ( 'Storing token...' , true ) ;
301+ try {
302+ const exT = getCookieExpiry ( idToken ) ;
303+ if ( exT ) {
304+ setDomainCookie ( tcJWTCookie , idToken , exT ) ;
305+ setDomainCookie ( v3JWTCookie , idToken , exT ) ;
306+ setDomainCookie ( tcSSOCookie , tcsso , exT ) ;
307+ } else {
308+ setCookie ( tcJWTCookie , idToken , cookieExpireIn ) ;
309+ setCookie ( v3JWTCookie , idToken , cookieExpireIn ) ;
310+ setCookie ( tcSSOCookie , tcsso , cookieExpireIn ) ;
301311 }
312+ } catch ( e ) {
313+ logger ( 'Error occured in fecthing token expiry time' , e . message ) ;
314+ }
302315
303- if ( user . show_onboarding_wizard ) {
304- redirectToOnboardingWizard ( ) ;
305- } else {
306- // session still active, but app calling login
307- if ( ! appUrl && returnAppUrl ) {
308- appUrl = returnAppUrl
309- }
310- redirectToApp ( ) ;
316+ if ( showOnboardingWizard ) {
317+ logger . info ( 'Take user to onboarding wizard' ) ;
318+ redirectToOnboardingWizard ( ) ;
319+ } else {
320+ // session still active, but app calling login
321+ if ( ! appUrl && returnAppUrl ) {
322+ appUrl = returnAppUrl
311323 }
312- } else {
313- logger ( "User active ? " , userActive ) ;
314- host = registerSuccessUrl ;
315- logout ( ) ;
324+ redirectToApp ( ) ;
316325 }
317- } ) . catch ( function ( e ) {
318- logger ( "Error in fetching token from auth0: " , e ) ;
319- } ) ;
326+ } else {
327+ logger ( "User active ? " , userActive ) ;
328+ host = registerSuccessUrl ;
329+ logout ( ) ;
330+ }
331+ } ) . catch ( function ( e ) {
332+ logger ( "Error in fetching token from auth0: " , e ) ;
320333 } ) ;
321334 } ;
322335
0 commit comments