The function contains the following functionalities:
The end-user’s details will be 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.
Note: For the purpose of this tutorial, we have coded an example logic for the Custom User Validation function where if the user's email provider is anyone other than Zylker Technology (@zylker.com) the end user will not be able to sign up to the application. You can either use the same or code a logic of your preference.
Copy the code given below and paste it in the index.js file in the BirthdayGreetings/functions/basic_function directory of your project, and save the file.
You can use any IDE of your choice to work with the application’s files.
Note: Please go through the code in this section to make sure you fully understand it.
Ensure that you change the domain name in line 6 with one that matches your requirement.
You can also use this SDK to code your own custom logic instead of the one implemented above.
Deploy the Function and Configure Custom User Validation
To apply this custom logic, we need to deploy this function to the console to ensure that it is available to enable the Custom User Validation option present in the console.
Info: You can also alternatively choose to deploy just the Custom User Validation function using the following command:
catalyst deploy –only functions:function_name
Function endpoints will be created for all of the functions. This will allow you to access the functions directly.
The functions will be deployed to the console. They can be accessed in the console using the Functions component in the Serverless section of the console.
Note: While we have deployed all of the functions of the project to the console, we will be redeploying them once again after we code the Advanced I/O and Job functions.
Now, go to the Authentication component present in the Cloud Scale section of the console and implement the following steps:
Navigate to the Whitelisting section in the Authentication component, and click the Custom User Validation toggle.
Select the Basic I/O function from the drop-down in the pop-up.
Click Configure.
The Custom User Validation function has been enabled for the project, and the end-users signing up for your application will now be additionally authenticated using this function.
Note: You can find out about all of the features present in the Whitelisting section form in this help document.