diff --git a/.circleci/config.yml b/.circleci/config.yml index f1e812a..3f8a712 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,6 +71,7 @@ workflows: only: - dev - hotfix/resendActivationEmail + - feat/plat-320 # Production builds are exectuted only on tagged commits to the # master branch. diff --git a/web-assets/auth0/dev-tenant/rules/onboardingChecklist.js b/web-assets/auth0/dev-tenant/rules/onboardingChecklist.js index 126c7f5..f630b35 100644 --- a/web-assets/auth0/dev-tenant/rules/onboardingChecklist.js +++ b/web-assets/auth0/dev-tenant/rules/onboardingChecklist.js @@ -105,23 +105,27 @@ function (user, context, callback) { if (data.length === 0) { // User doesn't have any traits with traitId onboarding_checklist and should be shown the onboarding wizard - context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'show_onboarding_wizard'] = true; - console.log('rule:onboarding-checklist:Setting show_onboarding_wizard to true'); + context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'onboarding_wizard'] = 'show'; + console.log('rule:onboarding-checklist:Setting onboarding_wizard to show'); return callback(null, user, context); } const onboardingChecklistTrait = data.filter((item) => item.traitId === 'onboarding_checklist')[0].traits; + let override = 'show'; for (let checklistTrait of onboardingChecklistTrait.data) { - if ( - checklistTrait.onboarding_wizard != null && - (checklistTrait.onboarding_wizard.status != null || // any valid status indicates user has already seen onboarding wizard and needn't be shown again. - checklistTrait.onboarding_wizard.skip) // for certain signup routes skip is set to true, and thus onboarding wizard needn't be shown - ) { + if (checklistTrait.onboarding_wizard != null) { + if ( checklistTrait.onboarding_wizard.status !== 'pending_at_user' || // any non pending_at_user status indicates OB was either seen or completed and can be skipped + checklistTrait.onboarding_wizard.skip ||// for certain signup routes skip is set to true, and thus onboarding wizard needn't be shown + checklistTrait.onboarding_wizard.override === 'skip') + { return callback(null, user, context); + } else if (checklistTrait.onboarding_wizard.override === 'useRetUrl') { + override = 'useRetUrl'; } + } } - + const profileCompletedData = onboardingChecklistTrait.data.length > 0 ? onboardingChecklistTrait.data[0].profile_completed : null; if (profileCompletedData) { @@ -137,8 +141,12 @@ function (user, context, callback) { } // All checks failed - indicating user newly registered and needs to be shown the onboarding wizard - console.log('rule:onboarding-checklist: set show_onboarding_wizard'); - context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'show_onboarding_wizard'] = true; + console.log('rule:onboarding-checklist: set onboarding_wizard ' + override); + + context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'onboarding_wizard'] = override; + + + return callback(null, user, context); } catch (e) { console.log("rule:onboarding-checklist:Error in fetching onboarding_checklist", e); diff --git a/web-assets/js/setupAuth0WithRedirect.js b/web-assets/js/setupAuth0WithRedirect.js index 5e0d233..b6404b7 100644 --- a/web-assets/js/setupAuth0WithRedirect.js +++ b/web-assets/js/setupAuth0WithRedirect.js @@ -233,7 +233,7 @@ const authSetup = function () { const redirectToOnboardingWizard = function () { logger("redirect to onboarding wizard"); - window.location = onboardingWizardUrl; + window.location = onboardingWizardUrl } const redirectToApp = function () { @@ -271,9 +271,9 @@ const authSetup = function () { let showOnboardingWizard = false; Object.keys(claims).forEach(key => { logger('Checking key', key); - if (key.indexOf('show_onboarding_wizard') !== -1) { - if (claims[key]) { - showOnboardingWizard = true; + if (key.indexOf('onboarding_wizard') !== -1) { + if (claims[key] === 'show' || claims[key] === 'useRetUrl') { + showOnboardingWizard = claims[key]; } } }); @@ -314,9 +314,13 @@ const authSetup = function () { } if (showOnboardingWizard) { - logger('Take user to onboarding wizard'); - redirectToOnboardingWizard(); - } else { + logger('Take user to onboarding wizard', showOnboardingWizard); + if (showOnboardingWizard === 'useRetUrl') { + setCookie('returnAfterOnboard', qs['appUrl'] || qs['retUrl']) + } + redirectToOnboardingWizard(returnAppUrl); + } + else { // session still active, but app calling login if (!appUrl && returnAppUrl) { appUrl = returnAppUrl