@@ -20,6 +20,8 @@ import (
2020 "net/http"
2121
2222 "github.com/supertokens/supertokens-golang/ingredients/emaildelivery"
23+ "github.com/supertokens/supertokens-golang/recipe/emailverification"
24+ "github.com/supertokens/supertokens-golang/recipe/emailverification/evmodels"
2325 "github.com/supertokens/supertokens-golang/recipe/thirdparty/api"
2426 "github.com/supertokens/supertokens-golang/recipe/thirdparty/tpmodels"
2527 "github.com/supertokens/supertokens-golang/supertokens"
@@ -55,6 +57,13 @@ func MakeRecipe(recipeId string, appInfo supertokens.NormalisedAppinfo, config *
5557 r .RecipeImpl = verifiedConfig .Override .Functions (MakeRecipeImplementation (* querierInstance ))
5658 r .Providers = config .SignInAndUpFeature .Providers
5759
60+ supertokens .AddPostInitCallback (func () {
61+ evRecipe := emailverification .GetRecipeInstance ()
62+ if evRecipe != nil {
63+ evRecipe .AddGetEmailForUserIdFunc (r .getEmailForUserId )
64+ }
65+ })
66+
5867 return * r , nil
5968}
6069
@@ -141,15 +150,21 @@ func (r *Recipe) handleError(err error, req *http.Request, res http.ResponseWrit
141150 return false , err
142151}
143152
144- func (r * Recipe ) getEmailForUserId (userID string , userContext supertokens.UserContext ) (string , error ) {
153+ func (r * Recipe ) getEmailForUserId (userID string , userContext supertokens.UserContext ) (evmodels. TypeEmailInfo , error ) {
145154 userInfo , err := (* r .RecipeImpl .GetUserByID )(userID , userContext )
146155 if err != nil {
147- return "" , err
156+ return evmodels. TypeEmailInfo {} , err
148157 }
149158 if userInfo == nil {
150- return "" , errors .New ("unknown User ID provided" )
159+ return evmodels.TypeEmailInfo {
160+ UnknownUserIDError : & struct {}{},
161+ }, nil
151162 }
152- return userInfo .Email , nil
163+ return evmodels.TypeEmailInfo {
164+ OK : & struct { Email string }{
165+ Email : userInfo .Email ,
166+ },
167+ }, nil
153168}
154169
155170func ResetForTest () {
0 commit comments