OhFlohre
04/03/2023, 11:45 AMrp_st
04/03/2023, 11:50 AMCreateEmailVerificationToken
function to get a email verification token. The input is a userId and email.
- Call the VerifyEmailUsingToken
function with the generated token.OhFlohre
04/03/2023, 11:52 AMrp_st
04/03/2023, 12:02 PMpackage 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
}
OhFlohre
04/03/2023, 12:44 PMrp_st
04/03/2023, 3:59 PM