@@ -263,59 +263,73 @@ const authSetup = function () {
263263 }
264264
265265 const storeToken = function ( ) {
266- auth0 . getUser ( ) . then ( function ( user ) {
267- auth0 . getIdTokenClaims ( ) . then ( function ( claims ) {
268- idToken = claims . __raw ;
269- 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 = '' ;
270293 Object . keys ( claims ) . findIndex ( function ( key ) {
271- if ( key . includes ( 'active' ) ) {
272- userActive = claims [ key ] ;
294+ if ( key . includes ( tcSSOCookie ) ) {
295+ tcsso = claims [ key ] ;
273296 return true ;
274297 }
275298 return false ;
276299 } ) ;
277- if ( userActive ) {
278- let tcsso = '' ;
279- Object . keys ( claims ) . findIndex ( function ( key ) {
280- if ( key . includes ( tcSSOCookie ) ) {
281- tcsso = claims [ key ] ;
282- return true ;
283- }
284- return false ;
285- } ) ;
286- logger ( 'Storing token...' , true ) ;
287- try {
288- const exT = getCookieExpiry ( idToken ) ;
289- if ( exT ) {
290- setDomainCookie ( tcJWTCookie , idToken , exT ) ;
291- setDomainCookie ( v3JWTCookie , idToken , exT ) ;
292- setDomainCookie ( tcSSOCookie , tcsso , exT ) ;
293- } else {
294- setCookie ( tcJWTCookie , idToken , cookieExpireIn ) ;
295- setCookie ( v3JWTCookie , idToken , cookieExpireIn ) ;
296- setCookie ( tcSSOCookie , tcsso , cookieExpireIn ) ;
297- }
298- } catch ( e ) {
299- 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 ) ;
300311 }
312+ } catch ( e ) {
313+ logger ( 'Error occured in fecthing token expiry time' , e . message ) ;
314+ }
301315
302- if ( user . show_onboarding_wizard ) {
303- redirectToOnboardingWizard ( ) ;
304- } else {
305- // session still active, but app calling login
306- if ( ! appUrl && returnAppUrl ) {
307- appUrl = returnAppUrl
308- }
309- 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
310323 }
311- } else {
312- logger ( "User active ? " , userActive ) ;
313- host = registerSuccessUrl ;
314- logout ( ) ;
324+ redirectToApp ( ) ;
315325 }
316- } ) . catch ( function ( e ) {
317- logger ( "Error in fetching token from auth0: " , e ) ;
318- } ) ;
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 ) ;
319333 } ) ;
320334 } ;
321335
0 commit comments