Skip to content

Commit 9fb883c

Browse files
author
sachin-maheshwari
authored
Merge pull request #301 from topcoder-platform/dev
feat: forward retUrl to onboard app for specific regSource's
2 parents 2a217c6 + 97b16d5 commit 9fb883c

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ workflows:
7171
only:
7272
- dev
7373
- hotfix/resendActivationEmail
74+
- feat/plat-320
7475

7576
# Production builds are exectuted only on tagged commits to the
7677
# master branch.

web-assets/auth0/dev-tenant/rules/onboardingChecklist.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,27 @@ function (user, context, callback) {
105105

106106
if (data.length === 0) {
107107
// User doesn't have any traits with traitId onboarding_checklist and should be shown the onboarding wizard
108-
context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'show_onboarding_wizard'] = true;
109-
console.log('rule:onboarding-checklist:Setting show_onboarding_wizard to true');
108+
context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'onboarding_wizard'] = 'show';
109+
console.log('rule:onboarding-checklist:Setting onboarding_wizard to show');
110110
return callback(null, user, context);
111111
}
112112

113113
const onboardingChecklistTrait = data.filter((item) => item.traitId === 'onboarding_checklist')[0].traits;
114+
let override = 'show';
114115

115116
for (let checklistTrait of onboardingChecklistTrait.data) {
116-
if (
117-
checklistTrait.onboarding_wizard != null &&
118-
(checklistTrait.onboarding_wizard.status != null || // any valid status indicates user has already seen onboarding wizard and needn't be shown again.
119-
checklistTrait.onboarding_wizard.skip) // for certain signup routes skip is set to true, and thus onboarding wizard needn't be shown
120-
) {
117+
if (checklistTrait.onboarding_wizard != null) {
118+
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
119+
checklistTrait.onboarding_wizard.skip ||// for certain signup routes skip is set to true, and thus onboarding wizard needn't be shown
120+
checklistTrait.onboarding_wizard.override === 'skip')
121+
{
121122
return callback(null, user, context);
123+
} else if (checklistTrait.onboarding_wizard.override === 'useRetUrl') {
124+
override = 'useRetUrl';
122125
}
126+
}
123127
}
124-
128+
125129
const profileCompletedData = onboardingChecklistTrait.data.length > 0 ? onboardingChecklistTrait.data[0].profile_completed : null;
126130

127131
if (profileCompletedData) {
@@ -137,8 +141,12 @@ function (user, context, callback) {
137141
}
138142

139143
// All checks failed - indicating user newly registered and needs to be shown the onboarding wizard
140-
console.log('rule:onboarding-checklist: set show_onboarding_wizard');
141-
context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'show_onboarding_wizard'] = true;
144+
console.log('rule:onboarding-checklist: set onboarding_wizard ' + override);
145+
146+
context.idToken[global.AUTH0_CLAIM_NAMESPACE + 'onboarding_wizard'] = override;
147+
148+
149+
142150
return callback(null, user, context);
143151
} catch (e) {
144152
console.log("rule:onboarding-checklist:Error in fetching onboarding_checklist", e);

web-assets/js/setupAuth0WithRedirect.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const authSetup = function () {
233233

234234
const redirectToOnboardingWizard = function () {
235235
logger("redirect to onboarding wizard");
236-
window.location = onboardingWizardUrl;
236+
window.location = onboardingWizardUrl
237237
}
238238

239239
const redirectToApp = function () {
@@ -271,9 +271,9 @@ const authSetup = function () {
271271
let showOnboardingWizard = false;
272272
Object.keys(claims).forEach(key => {
273273
logger('Checking key', key);
274-
if (key.indexOf('show_onboarding_wizard') !== -1) {
275-
if (claims[key]) {
276-
showOnboardingWizard = true;
274+
if (key.indexOf('onboarding_wizard') !== -1) {
275+
if (claims[key] === 'show' || claims[key] === 'useRetUrl') {
276+
showOnboardingWizard = claims[key];
277277
}
278278
}
279279
});
@@ -314,9 +314,13 @@ const authSetup = function () {
314314
}
315315

316316
if (showOnboardingWizard) {
317-
logger('Take user to onboarding wizard');
318-
redirectToOnboardingWizard();
319-
} else {
317+
logger('Take user to onboarding wizard', showOnboardingWizard);
318+
if (showOnboardingWizard === 'useRetUrl') {
319+
setCookie('returnAfterOnboard', qs['appUrl'] || qs['retUrl'])
320+
}
321+
redirectToOnboardingWizard(returnAppUrl);
322+
}
323+
else {
320324
// session still active, but app calling login
321325
if (!appUrl && returnAppUrl) {
322326
appUrl = returnAppUrl

0 commit comments

Comments
 (0)