Custom User Validation

Catalyst Authentication allows you to authorize and validate your end-users using a custom Basic I/O function on the event of a sign-up to your Catalyst application. You can write your own logic and process the credentials that the user provides through this function, and grant access to your application.

A sample code for a Custom User Validation function is given below.

copy
const catalyst = require('zcatalyst-sdk-node');
module.exports = (context, basicIO) => 
{
 const catalystApp = catalyst.initialize(context);
 const userManagement = catalystApp.userManagement();
 const requestDetails = userManagement.getSignupValidationRequest(basicIO);
 if (requestDetails!==undefined) 
{
  if (requestDetails.user_details.email_id.includes('zylker.com'))
{
   basicIO.write(JSON.stringify({
    status: 'failure'
}))
}
  else
{
   basicIO.write(JSON.stringify({
    status: 'success',
    user_details: 
    {
     first_name : 'CustomFirstName',
     last_name : 'CustomLastName',
     role_identifier : 'CustomRole',
     org_id : 'CustomOrgID'//If you are providing the Org ID, make sure it is copied exactly from the console.
    }
   }))
  }
}
 context.close();
}

To test this function, you can pass the details of the user in the following .JSON format:

copy
{
    "request_type": "add_user",
    "request_details": {
        "user_details": {
            "email_id": "emmy@zylker.com",
            "first_name": "Emma",
            "last_name": "Thompson",
            "org_id": "432567817",
            "role_details": {
                "role_name": "Moderator",
                "role_id": "879"
            }
        },
        "auth_type": "web"
    }
}

Last Updated 2024-02-10 13:06:26 +0530 IST

ON THIS PAGE

RELATED LINKS

Authentication