I am using the thirdpartypassword and emailverific...
# support-questions
t
I am using the thirdpartypassword and emailverification module with the Golang sdk. Is there a function to resend the verification email?
s
hi @Tyho, we do not have a single function that can do this. I can share a code snippet on how you can go about doing this
t
That would be great!
s
Copy code
go
package main

import (
    "fmt"

    "github.com/supertokens/supertokens-golang/ingredients/emaildelivery"
    "github.com/supertokens/supertokens-golang/recipe/emailverification"
    "github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless"
)

func sendEmailVerification(email string) {
    users, err := thirdpartypasswordless.GetUsersByEmail(email)
    if err != nil {
        // handle error
        return
    }
    for _, user := range users {
        if user.ThirdParty != nil { // Email verification is applicable only for thirdparty user
            tokenRes, err := emailverification.CreateEmailVerificationToken(user.ID, nil)
            if err != nil {
                // handle error
                return
            }

            if tokenRes.OK != nil {

                emailVerificationURL := fmt.Sprintf(
                    "%s%s/verify-email?token=%s&rid=emailverification",
                    "http://localhost:3000", // website domain
                    "/auth",                 // website base path
                    tokenRes.OK.Token,
                )
                emailverification.SendEmail(emaildelivery.EmailType{
                    EmailVerification: &emaildelivery.EmailVerificationType{
                        User: emaildelivery.User{
                            ID:    user.ID,
                            Email: *user.Email,
                        },
                        EmailVerifyLink: emailVerificationURL,
                    },
                })
            }
        }
    }
}
let me know if this helps
t
It worked, thanks!