Advanced Customization for Login Form
Configuration Reference
Here's an example of a complete configuration:
Description
Field Name
Description
Required
ApiKeyID
your API_KEY_ID
Y
Y
Type
"EMAIL"
or "PHONE"
Y
ContainerID
id
of the <div>
where you want to serve Cotter Form.
Y
Y
N
ButtonBackgroundColor
Button background color. Use HEX format (e.g. #000000
)
N
ButtonTextColor
Button text color. Use HEX format (e.g. #FFFFFF
)
N
ButtonText
Button text. Default is "Sign Up Without Password"
N
ErrorColor
Text color for error messages. Use HEX format (e.g. #FFFFFF
)
N
EventName
Tag this authentication event with a name, like WITHDRAWAL
to make it easier to segment your event logs.
N
IdentifierField
Field name for the identifier to include in the JSON obj. For example, if you want to include the phone number in the JSON obj under key "phone"
, then fill in IdentifierField = "phone"
Y
AllowOTPFallback
Allow user to choose to authenticate using OTP (One-Time-Password) instead of Trusted Device if they want.
N
Y
An Array of country code options for the user
N
AuthRequestText
A dictionary to customize the text in the authentication prompt
N
OnError
A function that will be called if there's an error, and will receive the error message or object
N
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