Skip to main content

Email Verification Code Login

Using email verification code login, you can allow users to log in with "email + email verification code".

Prerequisites

Enable Email Login

CloudBase provides a zero-configuration email service that requires no third-party email service application or SMTP parameter configuration, allowing you to complete the setup in just 1 minute.

Configuration Steps:

  1. Go to CloudBase Console / Identity Authentication / Login Methods
  2. Find the "Email Verification Code" card and click "Configure Sender Email"
  3. Select "Enable Email Proxy"
  4. Save the configuration, which takes effect immediately

After configuration, the email effect received by users:

User Registration

For user registration process, please refer to User Registration.

Email Verification Code Login

The Auth.signInWithEmail method is used for email verification code login.

const app = cloudbase.init({
env: "xxxx-yyy",
region: "ap-shanghai", // Defaults to Shanghai region if not specified
});

const auth = app.auth();

const email = "test@example.com";

// Step 1: When the user clicks to get the verification code, call the following method to send the email verification code, and store verificationInfo globally for use as a parameter in step 3
const verificationInfo = await auth.getVerification({
email: email,
});

// Step 2: Wait for the user to enter the email verification code on the page
const verificationCode = userInputCode; // 6-digit verification code

// Step 3: After the user enters the verification code, verify the email verification code and log in
await auth.signInWithEmail({
verificationInfo,
verificationCode, // Email verification code entered by the user
email: email, // User's email
});

Custom SMTP Configuration Guide

If you choose to use a custom SMTP email service, this section will help you complete the configuration for common email services.

QQ Mail

Step 1: Log in to QQ Mail

Go to QQ Mail Homepage and log in to your QQ mailbox.

Step 2: Enable IMAP/SMTP Service

After logging in to the mailbox, go to "Settings - Account":

Then, in the "Account" settings, find the "Enable Services" setting item and enable the IMAP/SMTP service:

After successful activation, please save your email login authorization code:

Note

You can also enable the POP3/SMTP service. The authorization codes for both services can be used as the SMTP account password in Step 3.

Step 3: Configure QQ Mail as Sender

Use your QQ mailbox as the sender address and SMTP account username, and use the authorization code from Step 2 as the SMTP account password.

Gmail

Step 1: Log in to Gmail

Gmail has IMAP/SMTP service enabled by default. This step verifies that the mailbox is available.

Step 2: Enable Google Account Two-Step Verification

Visit Google Account Security Settings, click "Security" → "2-Step Verification" to enable it.

Step 3: Enable Google Account App-Specific Password

Visit App-Specific Password Settings to generate an app-specific password.

Step 4: Configure CloudBase Console Email Login SMTP

Configuration ItemConfiguration Value
SenderYour Gmail address
SMTP Server Hostsmtp.gmail.com
Port465
SMTP Account UsernameYour Gmail address
SMTP Account PasswordApp-specific password from Step 3
SMTP Security ModeSSL