1
1
function ( user , context , callback ) {
2
2
if ( context . clientID === configuration . CLIENT_ACCOUNTS_LOGIN ) {
3
- console . log ( "rule:onboarding-checklist:enter" ) ;
3
+ // console.log("rule:onboarding-checklist:enter");
4
4
5
5
if ( context . redirect ) {
6
- console . log ( "rule:onboarding-checklist:exiting due to context being a redirect" ) ;
6
+ // console.log("rule:onboarding-checklist:exiting due to context being a redirect");
7
7
return callback ( null , user , context ) ;
8
8
}
9
9
@@ -13,19 +13,26 @@ function (user, context, callback) {
13
13
const isSocial = _ . get ( user , "identities[0].isSocial" ) ;
14
14
const connection = _ . get ( user , "identities[0].connection" ) ;
15
15
16
- console . log ( "rule:onboarding-checklist: isSocial/connection" , isSocial + "/" + connection ) ;
17
- console . log ( "rule:onboarding-checklist: WIPRO_SS_AZURE_AD_CONNECTION_NAME" , configuration . WIPRO_SSO_AZURE_AD_CONNECTION_NAME ) ;
16
+ // console.log("rule:onboarding-checklist: isSocial/connection", isSocial + "/" + connection);
17
+ // console.log("rule:onboarding-checklist: WIPRO_SS_AZURE_AD_CONNECTION_NAME", configuration.WIPRO_SSO_AZURE_AD_CONNECTION_NAME);
18
18
19
19
if ( _ . includes ( [ configuration . WIPRO_SSO_AZURE_AD_CONNECTION_NAME ] , connection ) ) {
20
- console . log ( "rule:onboarding-checklist:exiting due to user being an enterprise user." ) ;
20
+ // console.log("rule:onboarding-checklist:exiting due to user being an enterprise user.");
21
21
return callback ( null , user , context ) ;
22
22
}
23
23
24
24
const handle = context . idToken [ global . AUTH0_CLAIM_NAMESPACE + 'handle' ] ;
25
- console . log ( "rule:onboarding-checklist: fetch onboarding_checklist for email/handle: " , user . email , handle ) ;
25
+ // console.log("rule:onboarding-checklist: fetch onboarding_checklist for email/handle: ", user.email, handle);
26
26
27
- if ( handle == null ) {
28
- console . log ( "rule:onboarding-checklist: exiting due to handle being null." ) ;
27
+ if ( handle === null ) {
28
+ //console.log("rule:onboarding-checklist: exiting due to handle being null.");
29
+ return callback ( null , user , context ) ;
30
+ }
31
+
32
+ const roles = context . idToken [ global . AUTH0_CLAIM_NAMESPACE + 'roles' ] ;
33
+
34
+ if ( roles && roles . includes ( 'Topcoder Customer' ) ) {
35
+ console . log ( "rule:onboarding-checklist:exiting due to user being a customer." ) ;
29
36
return callback ( null , user , context ) ;
30
37
}
31
38
@@ -36,7 +43,7 @@ function (user, context, callback) {
36
43
// For users created before thresholdDate, we don't want to check onboarding_checklist
37
44
// This is because older profiles might not have onboarding_checklist data and they don't need to see the onboarding_wizard
38
45
if ( createdAt && ! thresholdDate . isBefore ( moment ( createdAt ) ) ) {
39
- console . log ( "rule:onboarding-checklist: user created before threshold date. Not checking onboarding_checklist." ) ;
46
+ // console.log("rule:onboarding-checklist: user created before threshold date. Not checking onboarding_checklist.");
40
47
return callback ( null , user , context ) ;
41
48
}
42
49
} catch ( err ) {
@@ -48,18 +55,18 @@ function (user, context, callback) {
48
55
*/
49
56
const getToken = function ( callback ) {
50
57
if ( global . M2MToken ) {
51
- console . log ( 'rule:onboarding-checklist:M2M token is available' ) ;
58
+ // console.log('rule:onboarding-checklist:M2M token is available');
52
59
const jwt = require ( 'jsonwebtoken' ) ;
53
60
const decoded = jwt . decode ( global . M2MToken ) ;
54
61
const exp = moment . unix ( decoded . exp ) ;
55
62
56
63
if ( exp > new Date ( ) ) {
57
- console . log ( 'rule:onboarding-checklist:M2M token is valid. Reusing...' ) ;
64
+ // console.log('rule:onboarding-checklist:M2M token is valid. Reusing...');
58
65
return callback ( null , global . M2MToken ) ;
59
66
}
60
67
}
61
68
62
- console . log ( 'rule:onboarding-checklist:Fetching new M2M token' ) ;
69
+ // console.log('rule:onboarding-checklist:Fetching new M2M token');
63
70
request . post ( {
64
71
url : `https://auth0proxy.${ configuration . DOMAIN } /token` ,
65
72
headers : 'content-type: application/json' ,
@@ -76,14 +83,14 @@ function (user, context, callback) {
76
83
}
77
84
78
85
global . M2MToken = body . access_token ;
79
- console . log ( 'rule:onboarding-checklist:setting the M2MToken globally' , global . M2MToken ) ;
86
+ // console.log('rule:onboarding-checklist:setting the M2MToken globally', global.M2MToken);
80
87
return callback ( null , global . M2MToken ) ;
81
88
} ) ;
82
89
} ;
83
90
84
91
getToken ( function ( err , token ) {
85
92
if ( err ) {
86
- console . log ( 'rule:onboarding-checklist:failed to fetch M2M token.' ) ;
93
+ // console.log('rule:onboarding-checklist:failed to fetch M2M token.');
87
94
return callback ( null , user , context ) ;
88
95
}
89
96
global . AUTH0_CLAIM_NAMESPACE = "https://" + configuration . DOMAIN + "/" ;
@@ -114,7 +121,7 @@ function (user, context, callback) {
114
121
let override = 'show' ;
115
122
116
123
for ( let checklistTrait of onboardingChecklistTrait . data ) {
117
- if ( checklistTrait . onboarding_wizard != null ) {
124
+ if ( checklistTrait . onboarding_wizard !== null ) {
118
125
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
126
checklistTrait . onboarding_wizard . skip || // for certain signup routes skip is set to true, and thus onboarding wizard needn't be shown
120
127
checklistTrait . onboarding_wizard . override === 'skip' )
0 commit comments