Skip to main content

Manually changing email verification status

Mark email as verified#

To manually mark an email as verified, you need to first create an email verification token for the user and then use the token to verify the user's email.

import EmailVerification from "supertokens-node/recipe/emailverification";

async function manuallyVerifyEmail(userId: string) {
try {
// Create an email verification token for the user
const tokenRes = await EmailVerification.createEmailVerificationToken(userId);

// If the token creation is successful, use the token to verify the user's email
if (tokenRes.status === "OK") {
await EmailVerification.verifyEmailUsingToken(tokenRes.token);
}
} catch (err) {
console.error(err);
}
}
Multi Tenancy

For a multi tenant setup, you need not give a tenant ID to the function calls above since a user ID and their email verification status is unique on an app level (and not a tenant level).

Mark email as unverified#

To manually mark an email as unverified, you need to first retrieve the user's email address and then update their email verification status in the database.

import EmailVerification from "supertokens-node/recipe/emailverification";

async function manuallyUnverifyEmail(userId: string) {
try {
// Set email verification status to false
await EmailVerification.unverifyEmail(userId);
} catch (err) {
console.error(err);
}
}
Multi Tenancy

For a multi tenant setup, the function above does not take a tenant ID since a user ID and their email verification status is unique on an app level (and not a tenant level).

Which UI do you use?
Custom UI
Pre built UI