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);
}
}

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);
}
}
Which UI do you use?
Custom UI
Pre built UI