Skip to main content
Version: 2.0.0-beta

Email Verification

Email verification works by establishing a WebSocket connection between the client and the server. When a user attempts to verify their email, the client sends a verification request to the server. The server then processes the request and resolves it with a message indicating whether the email has been successfully verified or not.

This WebSocket-based approach allows for real-time communication between the client and the server, ensuring that the verification status is promptly updated and reflected to the user.

Below are a few examples of how to register/authenticate a user using our SDKs. If you'd like a more detailed look at the API, please take a look at the OpenAPI Specs.


Prerequisites

Create Web Tenant

Use an existing tenant or create a new one to obtain the project base URL and application ID.

Register a User via Email

Below is an example using our Web SDK Javascript to register a user via email verification.

import { LoginIdConfiguration, LoginIdEmail } from "@loginid/web-sdk";

// Obtain credentials from LoginID Tenant
const BASE_URL = process.env.BASE_URL;
const APP_ID = process.env.APP_ID;

// Initialize the SDK with your configuration
const config = new LoginIdConfiguration(BASE_URL, APP_ID);

// Use the SDK components for signup and signin
const lid = new LoginIdEmail(config);

// Button click handler
async function handleSignupButtonClick() {
const username = "johnny@email.com";

try {
// Sign up with email
const signupResult = await lid.signupWithEmail(username);
// Handle the signup result
console.log("Signup Result:", signupResult);
} catch (error) {
// Handle errors
console.error("Error during signup:", error);
}
}

// Attach the click handler to a button
const signupButton = document.getElementById("signupButton"); // Assuming you have a button with id 'signupButton'
signupButton.addEventListener("click", handleSignupButtonClick);

Authenticate a User via Email

Below is an example using our Web SDK Javascript to authenticate a user via email verification.

import { LoginIdConfiguration, LoginIdEmail } from "@loginid/web-sdk";

// Obtain credentials from LoginID Tenant
const BASE_URL = process.env.BASE_URL;
const APP_ID = process.env.APP_ID;

// Initialize the SDK with your configuration
const config = new LoginIdConfiguration(BASE_URL, APP_ID);

// Use the SDK components for signup and signin
const lid = new LoginIdEmail(config);

// Button click handler
async function handleSigninButtonClick() {
const username = "johnny@email.com";

try {
// Sign up with email
const signinResult = await lid.signinWithEmail(username);
// Handle the signup result
console.log("Signup Result:", signinResult);
} catch (error) {
// Handle errors
console.error("Error during signup:", error);
}
}

// Attach the click handler to a button
const signinButton = document.getElementById("signinButton"); // Assuming you have a button with id 'signupButton'
signupButton.addEventListener("click", handleSigninButtonClick);

More Examples

  • Check out our quickstart guide to learn how to:
    • sign up a user with email verification followed by adding a passkey using the WebSDK.
    • use email verification sign-in as a fallback if passkey sign in fails or is unavailable with the WebSDK.