Cotter
  • 🚀Getting Started
  • Features & Concepts
    • 💬Sign In with Email/Phone Number
    • 🔐Sign In with Device
      • How it works
    • 🧬Sign In with WebAuthn
  • 📌Quickstart Guides
    • All Guides & Tutorials
    • HTML – Sign in with Email/Phone
    • React – Sign in with Email/Phone
    • React – WebAuthn
    • ▲ Next.js
    • Angular
    • Webflow
    • Bubble.io
    • Python SDK for a CLI
    • React Native – Sign in with Device
    • iOS – Sign in with Device
    • Flutter – Sign in with Device
  • 📘SDK Reference
    • Web
      • Sign In with Email/Phone Number
        • Customize the Form
        • Checking the email or phone before sending a verification code
        • Sending Code or Link via WhatsApp
        • Styling
        • Older SDK
          • Customize the Form
      • Sign in with Social Login
        • Getting Access Tokens from Social Login Providers
        • Github Instructions
        • Google Instructions
      • Sign In with WebAuthn
        • Register WebAuthn for a logged-in user
      • Sign In with Device
        • Steps for Pop Up Authentication Prompt
        • Advanced Customization for Login Form
        • Advanced Customization for Pop Up Authentication Prompt
      • Getting Access Token and Logged-In User Info
      • Sending Successful Form Submission
      • FAQ & Troubleshooting
    • React Native
      • Installation
      • Sign In with Device
        • Add Email/Phone Verification
        • Authenticate from a Non-Trusted Device
        • Add a new Trusted Device
        • Remove Trusted Device
      • Sign In with Email/Phone Number
      • Getting Stored OAuth Tokens and User Information
      • FAQ
      • Older SDK Versions
        • Sign in with Email/Phone
        • Sending Code via WhatsApp
        • Sign In with Device
          • Authenticate from a Non-Trusted Device
          • Add a new Trusted Device
          • Customization
    • Flutter
      • Sign In with Device
        • Add Email/Phone Verification
        • Authenticate from a Non-Trusted Device
      • Sign in with Email/Phone Number
      • Getting the Logged-in User
      • Getting OAuth Tokens
      • Signing a User Out
    • iOS
      • Sign In with Email/Phone Number
      • Sign In with Device
        • Authenticate from a Non-Trusted Device
        • Push Notification
        • Check if Trusted Device is Enrolled
        • Add a New Trusted Device
        • Remove Trusted Device
      • Older Versions
        • Biometric/Pin
    • Android
      • Sign In with Device
        • Authenticate from a Non-Trusted Device
        • Check if Trusted Device is Enrolled
        • Add a new Trusted Device
        • Remove Trusted Device
        • Customization
      • Sign In with Email/Phone Number
      • Biometric/Pin
        • Advanced Methods
        • Customization
        • Setting Strings
        • Styling
      • Older SDK Version
        • Sign In with Device
          • Authenticate from a Non-Trusted Device
    • Python (for CLI)
    • API for Other Mobile Apps or CLI
      • Verify Email/Phone Number
        • Handling URL Scheme
    • Backend: Handling Response
  • 🛡️ Protecting Your Account
    • Only Allow Your Website/App to Use Your API Key
    • Rate Limit
    • Enable reCAPTCHA to Protect Against Automated Abuse
  • 🗝️ Getting Access Token
    • Cotter's OAuth 2.0 Tokens Specification
    • Getting the Tokens
      • Get Tokens during Authentication
      • Using the Refresh Token
    • Storing and Removing Tokens
    • Renewing Expired Tokens
    • Verifying JWT Tokens
    • Requesting Custom Fields on your JWT Token
    • Older API
      • Using HTTP Requests
      • Getting the Tokens
        • During Authentication
          • During Email/Phone Verification
        • During enrolling Trusted Devices
  • 🔌API Reference
    • User API
      • User Object
    • OAuth Tokens API
      • Verify JWT Token using API (serverless)
      • Requesting Custom Claims on your Access Token
      • Older API
    • OAuth Tokens from Social Login
    • Event Object
    • Reset PIN API
  • Older API
    • Validating Cotter's Identity Token
    • Validating Cotter's Event Response
Powered by GitBook
On this page
  • Customize the Form from the Dashboard
  • Advanced Configuration Reference
  • Description
  • Additional Fields
  • OnBegin
  • CountryCode
  1. SDK Reference
  2. Web
  3. Sign In with Email/Phone Number

Customize the Form

PreviousSign In with Email/Phone NumberNextChecking the email or phone before sending a verification code

Last updated 4 years ago

Customize the Form from the Dashboard

You can now customize the form from > Project > Design.

Customizable Features that are not available in the Dashboard:

Advanced Configuration Reference

You can use our advanced config to have more functionality:

Usage:

var cotter = new Cotter(config); // 👈 Put the config in here

  cotter
    .signInWithLink()
    .showEmailForm()
    .then(payload => {})
    .catch(err => {});

Config:

Here's an example of a complete configuration:

var config = {
  // Required Basic Configuration
  ApiKeyID: "<your-API-KEY-ID>",
  Type: "PHONE", // EMAIL or PHONE
  ContainerID: "cotter-container-signup",
  IdentifierField: "phone",

  // Change Country Code
  CountryCode: ["+62"], // IT HAS TO BE AN ARRAY

  // Styling
  ButtonBackgroundColor: "#000000",
  ButtonTextColor: "#ffffff",
  ButtonText: "Sign Up Now",
  ButtonBorderColor: "#D2D3FF", // don't specify for no border

  // Adding fields
  AdditionalFields: [
    {
      label: "Full Name",
      name: "name",
      placeholder: "Enter your full name"
    }
  ],

  // Intercepting before authentication is processed
  OnBegin: payload => {
    if (payload.identifier != "+12345678910") {
      return "Phone Number is not allowed";
    }
    return null;
  },
  
  // Add WhatsApp option to send verification code
  // (only for type = PHONE)
  // ################################################
  // # 👈Please read the section about WhatsApp 👈 #
  // #       to comply with WhatsApp's Policy       # 
  // ################################################
  PhoneChannels: ["SMS", "WHATSAPP"], // default = ["SMS"]
  
  // WhatsApp Button Styling
  ButtonWAText: "Continue with",
  ButtonWATextSubtitle:
    "Tell your customer that you'll be sending the verification code via WhatsApp",
  ButtonWABackgroundColor: "#128C7E",
  ButtonWABorderColor: "#075E54",
  ButtonWATextColor: "#ffffff",
  ButtonWALogoColor: "white",
};

Description

Field Name

Description

Required

ApiKeyID

your API_KEY_ID

Y

Type

"EMAIL" or "PHONE"

Y

ContainerID

id of the <div> where you want to serve Cotter Form.

Y

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

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

N

An Array of country code options for the user

N

PhoneChannels

An Array of channels to send verification code to your users. Default value is ["SMS"].Available values are SMS and WHATSAPP. For example, to allow both SMS and WhatsApp, specify ["SMS", "WHATSAPP"]

N

Additional Fields

The additional fields will be used to generate more <input> fields for your users. The format is as following:

var config = {
  ...
  AdditionalFields: [
          {
            label: "Full Name",
            name: "name",
            placeholder: "Enter your full name"
          },
          {
            label: "Address",
            name: "address",
            placeholder: "Enter your address"
          },
          {
            label: "Prefilled Info",
            name: "prefilled",
            type: "hidden", // type can be "hidden", "text" or "number"
            initial_value: "autofill value"
          }
        ],
}

Available types: hidden, text, number

JSON Object to be sent to RedirectURL:

{
  "token": {...},
  [IdentifierField]: "+12345678910",

  // Additional Fields
  "name": "Hello World",
  "address": "Street Address",
  "prefilled": "autofill value"
  ...
}

OnBegin

This function will be invoked before the Signup/Login process. You will receive the following payload as a parameter to your function

Payload passed into your OnBegin function

var payload = {
  identifier: "+12345678910",
  identifier_type: "PHONE",
  device_type: "BROWSER",
  device_name: "Chrome ..."
};

You can do a check against the identifier here before the form is submitted.

If you include OnBegin key, you have to either return an error string, or return null if you want to continue the authentication process:

A. If you want to continue submission:

return null;

B. If you want to stop submission with an error:

return "Your error message";

Example:

 OnBegin: payload => {
  if (payload.identifier != "+12345678910") {
    return "Phone Number is not allowed";
  }
  // No error, continue submission
  return null;
},

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

CountryCode: ["+1"];

ex. with 2 country codes

CountryCode: ["+62", "+91"];

Our SMS and WhatsApp messaging works worldwide!

Additional fields that you want to include in the JSON obj. Check the specs for below

A function that will be called before the signup process begin. Check the specs for below

This will be sent to you to the endpoint above as part of the JSON object. For example, with the fields above, you'll get a JSON object like the following.

📘
Advanced Styling
Cotter's Dashboard
Add Additional fields
RedirectURL
AdditionalFields
Additional Fields Object
OnBegin
OnBegin
CountryCode