Configure the Basic I/O Function
Now, we will begin coding the authorization portal application by configuring the function component.
The function’s directory, (functions/authorization_portal_function), contains:
- The index.js main function file
- The catalyst-config.json configuration file
- Node modules
- package.json and package-lock.json dependency files
You will be adding code in the index.js file.
The Basic I/O function contains the following functionalities:
- The end-user’s details will provided as a JSON input to the Custom User Validation function.
- The function is coded to implement a custom logic based upon which the end-user will either be authenticated or denied.
Now, let’s begin coding the Basic I/O function.
Copy the code given below and paste it in the index.js file in the functions/authorization_portal_function directory of your project, and save the file. You can use any IDE of your choice to work with the application’s files.
const catalyst = require('zcatalyst-sdk-node')
module.exports = (context, basicIO) => {
const catalystApp = catalyst.initialize(context)
const requestDetails = catalystApp.userManagement().getSignupValidationRequest(basicIO)
if (requestDetails) {
if (requestDetails.user_details.email_id.includes('@zylker.com')) {
// The actions that occur in the event of a successful authentication can be customized
basicIO.write(JSON.stringify({
status: 'success',
user_details:
{
first_name: requestDetails.user_details.first_name,
last_name: requestDetails.user_details.last_name,
email_id: requestDetails.user_details.email_id,
role_identifier: 'App User', // If you want to override the default role, you can specify the role id/name here.
org_id: '' // If you are providing the Org ID, make sure it is copied exactly from the console.
}
}))
} else {
// The user has failed authentication
basicIO.write(JSON.stringify({
status: 'failure'
}))
}
}
context.close()
}
The function directory is now configured. We can now proceed to configuring the client directory.
Last Updated 2025-11-19 20:37:41 +0530 IST