How can i manually set the email verification stat...
# support-questions-legacy
o
How can i manually set the email verification status in golang?
r
Hey. So this can be done by using two functions from the emailverification recipe (https://pkg.go.dev/github.com/supertokens/supertokens-golang/recipe/emailverification) - Call the
CreateEmailVerificationToken
function to get a email verification token. The input is a userId and email. - Call the
VerifyEmailUsingToken
function with the generated token.
o
Okay thank you
r
This should be the code snippet:
Copy code
package main

import (
    "github.com/supertokens/supertokens-golang/recipe/emailverification"
)

func manuallyVerifyEmail(userID string) error {
    // Create an email verification token for the user
    tokenRes, err := emailverification.CreateEmailVerificationToken(userID, nil)
    if err != nil {
        return err
    }

    // If the token creation is successful, use the token to verify the user's email
    if tokenRes.OK != nil {
        _, err := emailverification.VerifyEmailUsingToken(tokenRes.OK.Token)
        if err != nil {
            return err
        }
    }

    return nil
}
o
Thanks a lot. It works
r
supertokens-bot-test-case
5 Views