@earnaha/auth0-action-helper v1.3.4
AHA auth0 action helper
Create custom actions in auth0
- login auth0 account
- create a action: e.g.
actions
→Flows
→Login
→Add Action
→Build Custom
- initialize the action:
name = Post Login Trigger = Login / Post Login Runtime = Node 16
- click
Create
Add dependencies
- click the cube icon in the left side of codes
- click
Add Dependency
name = @earnaha/auth0-action-helper version = 1.0.21 or latest
- click
Create
Setup event secrets
- click the key icon in the left side of codes
- click
Add Secret
, input keys and values like below, and then clickCreate
for each one.- ENV = local, dev, test, stage, alpha, beta, gamma, prod, ...etc.
- SERVICE = any string to distinguish your sites or services.
- DOMAIN = https://subdomain.yourdomain.com (backend url, https required)
- ACCESS_KEY = the secret key to access your backend api, encode string more than 25 letters
- ACCESS_SALT = the secret salt to access your backend api, a number more than 10 digits
- AUTH0_DOMAIN =
Applications
→Applications
→Machine to Machine App
→Settings
→Basic Information
→Domain
- AUTH0_CLIENT_ID =
Applications
→Applications
→Machine to Machine App
→Settings
→Basic Information
→Client ID
- AUTH0_CLIENT_SECRET =
Applications
→Applications
→Machine to Machine App
→Settings
→Basic Information
→Client Secret
- SENTRY_DSN = the sentry dns for logging, a sentry account is required. (https://sentry.io/)
- SENTRY_TRACES_SAMPLE_RATE = the sentry trace setting. e.g. 0.1, 1.0, ...etc.
- SENTRY_LOGGER_LEVEL = the sentry logger level setting. e,g, debug, info, ...etc.
- LINK_ACCOUNT_TIME = YYYY-MM-DD, account created after this date, merge accounts if having the same email.
Code in actions
Post login
make an API in your backend side with the route /auth/v3/login to handle the signed in/up account data.
const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
try {
const helper = new AhaHelper.PostLoginHelper(event.secrets);
const res = await helper.exec(event, api);
console.log('onExecutePostLogin res=',res);
} catch (e) {
console.error('onExecutePostLogin error=', e?.response?.data || e.message);
throw e;
}
};
Post change password
make an API in your backend side with the route /auth/v3/refer/invitation/accept to handle the invitation acceptance things after the invited account signs in/up.
const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PostChangePassword flow.
*
* @param {Event} event - Details about the user and the context in which the change password is happening.
* @param {PostChangePasswordAPI} api - Methods and utilities to help change the behavior after a user changes their password.
*/
exports.onExecutePostChangePassword = async (event, api) => {
try {
const helper = new AhaHelper.PostChangePasswordHelper(event.secrets);
const res = await helper.exec(event, api);
console.log('onExecutePostChangePassword res=',res);
} catch (e) {
console.error('onExecutePostChangePassword error=', e?.response?.data || e.message);
throw e;
}
};
Post user registration
currently no further handling in the exec function.
const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PostUserRegistration flow.
*
* @param {Event} event - Details about the context and user that has registered.
* @param {PostUserRegistrationAPI} api - Methods and utilities to help change the behavior after a signup.
*/
exports.onExecutePostUserRegistration = async (event, api) => {
try {
const helper = new AhaHelper.PostUserRegistrationHelper(event.secrets);
const res = await helper.exec(event, api);
console.log('onExecutePostUserRegistration res=',res);
} catch (e) {
console.error('onExecutePostUserRegistration error=', e?.response?.data || e.message);
throw e;
}
};
Pre user registration
currently no further handling in the exec function.
const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PreUserRegistration flow.
*
* @param {Event} event - Details about the context and user that is attempting to register.
* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.
*/
exports.onExecutePreUserRegistration = async (event, api) => {
try {
const helper = new AhaHelper.PreUserRegistrationHelper(event.secrets);
const res = await helper.exec(event, api);
console.log('onExecutePreUserRegistration res=',res);
} catch (e) {
console.error('onExecutePreUserRegistration error=', e?.response?.data || e.message);
throw e;
}
};
Deploy and test
3 days ago
6 days ago
6 days ago
7 days ago
7 days ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
7 months ago
7 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago