Advanced Customization for Login Form
Configuration Reference
Here's an example of a complete configuration:
Description
RedirectURL
We will send a JSON Object to this backend URL. The JSON Object will have the following format:
Description:
payload.client_user_id
Contains your user's user_id
that you used when registering the user to Cotter. This should be the user_id
from your backend.
payload.event
The event tag that you specified. The default value is LOGIN_WEB
. You should specify this with a relevant tag, like WITHDRAW
,PAYMENT
,etc. You can specify it using the EventName
attribute in the config.
Validate the event response
You should validate the event response to make sure it comes from Cotter's server
Skip RedirectURL
If you want to handle Cotter's Event Response in a function instead of sending it to your backend redirect_url
, you can specify
When this is true, the JSON payload as specified in RedirectURL section will be passed into your OnSuccess function.
OnBegin
This function will be invoked before the Login process. You are expected to return a user_id
at the end of the function. You will receive the following payload as a parameter to your function
Payload passed into your OnBegin function
You can do a check against the
identifier
here before the form is submitted.You should get the
user_id
based on the identifier in your backend (or use the identifier if that's what you used). This should be the same as the user id used in the Required Steps.
A. If there is no error:
B. If there is an error:
Example:
OnSuccess
This function will be called after the call to RedirectURL
is successful. Your function will receive the payload returned from RedirectURL
.
It is recommended to set your sessions or cookies here, and then redirect to another page in your website. For example:
OnSuccess when SkipRedirectURL is true
When you set SkipRedirectURL: true
, OnSuccess
will instead receive the JSON Event REsponse that was described in RedirectURL section.
CountryCode
The default value is CountryCode: ["+1"];
If you specify this, you have to use an array even though you only need 1 country code!
ex. with 1 country code
ex. with 2 country codes
Currently, the only available countries are United States, India and Indonesia. Chat us on Intercom if you need other countries, we just need to switch it on.
AllowOTPFallback
If you set this to true, your users will have the option to use OTP to login/authenticate. You should set OTP Fallback as true in your dashboard under Rules.
Last updated