4.1 Create an Action - Group
On this page
1. Open the CIC management dashboard
2. Under Actions, click on Library
3. Click on Build Custom
4. Name it as “Authfest VIPs”
Click on Create to set up the Action.
6. Paste this code into your action
// Adds a custom claim "group" with the value "VIP" if the user's email ends in "@authfest.com".
//
// @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) => {
// Check if the user's email ends with "@authfest.com".
if (event.user.email.endsWith('@authfest.com')) {
// Add the custom claim "status" with the value "VIP" to the access Token.
api.accessToken.setCustomClaim('group','VIP');
}
else{
// Add the custom claim "status" with the value "REGULAR" to the access Token.
api.accessToken.setCustomClaim('group','GENERAL');
}
};
7. Click on Deploy
8. Click on Flows
9. Click on the Login Flow
We are now going to include the action in the login flow.
10. Click on Custom
11. Drag and drop your action
12. Click on Apply
Your flow is going to be updated
13. Done!
Every time a user logs in now, it will run our action. If the user logs in with an email that ends with “@authfest.com”, their access token will receive a new “VIP” claim.
P.S.: Worried about the latency such an action causes? Don’t be - simple actions like that mostly run in far less than 50 ms, and are always available and ready to go. Check your tenants logs after your next login to see the impact!