-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* npm run format * npm run build * bump version
- Loading branch information
1 parent
77f172a
commit 225050c
Showing
6 changed files
with
149 additions
and
103 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/** | ||
* @title Arengu Progressive Profiling | ||
* @title Arengu Progressive Profiling | ||
* @overview Capture new users' information in your authentication flows. | ||
* @gallery true | ||
* @category marketplace | ||
*/ | ||
|
||
async function arenguCompleteUserProfile(user, context, callback) { | ||
async function arenguCompleteUserProfile(user, context, callback) { | ||
if ( | ||
!configuration.SESSION_TOKEN_SECRET || | ||
!configuration.ARENGU_PROFILE_FORM_URL | ||
|
@@ -17,7 +17,7 @@ | |
const { | ||
Auth0RedirectRuleUtilities, | ||
Auth0UserUpdateUtilities | ||
} = require("@auth0/[email protected]"); | ||
} = require('@auth0/[email protected]'); | ||
|
||
const ruleUtils = new Auth0RedirectRuleUtilities( | ||
user, | ||
|
@@ -42,14 +42,16 @@ | |
} | ||
|
||
function isEmptyUserMeta(key) { | ||
return userUtils.getUserMeta(key) === undefined || | ||
return ( | ||
userUtils.getUserMeta(key) === undefined || | ||
userUtils.getUserMeta(key) === null || | ||
userUtils.getUserMeta(key).length === 0; | ||
userUtils.getUserMeta(key).length === 0 | ||
); | ||
} | ||
|
||
function isProfileIncomplete() { | ||
// Add your required user_medata keys | ||
return isEmptyUserMeta('job_title') || isEmptyUserMeta('company_name'); | ||
return isEmptyUserMeta('job_title') || isEmptyUserMeta('company_name'); | ||
} | ||
|
||
if (ruleUtils.isRedirectCallback && ruleUtils.queryParams.session_token) { | ||
|
@@ -74,4 +76,4 @@ | |
} | ||
|
||
return callback(null, user, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,21 @@ async function incogniaOnboardingRule(user, context, callback) { | |
const { IncogniaAPI } = require('@incognia/[email protected]'); | ||
const { Auth0UserUpdateUtilities } = require('@auth0/[email protected]'); | ||
|
||
const { INCOGNIA_CLIENT_ID, INCOGNIA_CLIENT_SECRET, INCOGNIA_HOME_ADDRESS_PROP } = configuration; | ||
const { | ||
INCOGNIA_CLIENT_ID, | ||
INCOGNIA_CLIENT_SECRET, | ||
INCOGNIA_HOME_ADDRESS_PROP | ||
} = configuration; | ||
|
||
if (!INCOGNIA_CLIENT_ID || !INCOGNIA_CLIENT_SECRET) { | ||
console.log('Missing required configuration. Skipping.'); | ||
return callback(null, user, context); | ||
} | ||
|
||
const installationId = _.get(context, 'request.query.incognia_installation_id'); | ||
const installationId = _.get( | ||
context, | ||
'request.query.incognia_installation_id' | ||
); | ||
if (!installationId) { | ||
console.log('Missing installation_id. Skipping.'); | ||
return callback(null, user, context); | ||
|
@@ -27,7 +34,8 @@ async function incogniaOnboardingRule(user, context, callback) { | |
// User home address should be set using Auth0's Signup API for example. If the home address is | ||
// not in 'user_metadata.home_address', please specify the path of the field inside the user | ||
// object where the home address is through the INCOGNIA_HOME_ADDRESS_PROP configuration. | ||
const homeAddressProp = INCOGNIA_HOME_ADDRESS_PROP || 'user_metadata.home_address'; | ||
const homeAddressProp = | ||
INCOGNIA_HOME_ADDRESS_PROP || 'user_metadata.home_address'; | ||
const homeAddress = _.get(user, homeAddressProp); | ||
if (!homeAddress) { | ||
console.log('Missing user home address. Skipping.'); | ||
|
@@ -39,7 +47,9 @@ async function incogniaOnboardingRule(user, context, callback) { | |
const status = userUtils.getAppMeta('status'); | ||
// This rule was previously run and calculated the assessment successfully. | ||
if (status && status !== 'pending') { | ||
console.log('Assessment is already calculated or is unevaluable. Skipping.'); | ||
console.log( | ||
'Assessment is already calculated or is unevaluable. Skipping.' | ||
); | ||
return callback(null, user, context); | ||
} | ||
|
||
|
@@ -59,12 +69,14 @@ async function incogniaOnboardingRule(user, context, callback) { | |
// The rule was previously run, but Incognia could not assess the signup. | ||
if (signupId) { | ||
try { | ||
onboardingAssessment = await incogniaAPI.getOnboardingAssessment(signupId); | ||
onboardingAssessment = await incogniaAPI.getOnboardingAssessment( | ||
signupId | ||
); | ||
} catch (error) { | ||
console.log('Error calling Incognia API for signup previously submitted'); | ||
return callback(error); | ||
} | ||
// This is the first time the rule is being run with all necessary arguments. | ||
// This is the first time the rule is being run with all necessary arguments. | ||
} else { | ||
try { | ||
onboardingAssessment = await incogniaAPI.registerOnboardingAssessment({ | ||
|
@@ -90,7 +102,8 @@ async function incogniaOnboardingRule(user, context, callback) { | |
} else if (!firstAssessmentAt) { | ||
newStatus = 'pending'; | ||
} else { | ||
const firstAssessmentAge = Math.round(Date.now() / 1000) - firstAssessmentAt; | ||
const firstAssessmentAge = | ||
Math.round(Date.now() / 1000) - firstAssessmentAt; | ||
// 48 hours limit. | ||
if (firstAssessmentAge > 172800) { | ||
newStatus = 'unevaluable'; | ||
|