Skip to content

Commit 5804008

Browse files
committed
Changes based on PR review
1 parent de4be5c commit 5804008

File tree

8 files changed

+90
-58
lines changed

8 files changed

+90
-58
lines changed

recipe/dashboard/api/utils.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,51 @@ func GetUserForRecipeId(userId string, recipeId string) (user dashboardmodels.Us
123123
}
124124

125125
func IsRecipeInitialised(recipeId string) bool {
126+
isRecipeInitialised := false
127+
126128
if recipeId == emailpassword.RECIPE_ID {
127129
_, err := emailpassword.GetRecipeInstanceOrThrowError()
128130

129-
return err == nil
131+
if err == nil {
132+
isRecipeInitialised = true
133+
}
134+
135+
if !isRecipeInitialised {
136+
_, tpepErr := thirdpartyemailpassword.GetRecipeInstanceOrThrowError()
137+
138+
if tpepErr == nil {
139+
isRecipeInitialised = true
140+
}
141+
}
130142
} else if recipeId == passwordless.RECIPE_ID {
131143
_, err := passwordless.GetRecipeInstanceOrThrowError()
132144

133-
return err == nil
145+
if err == nil {
146+
isRecipeInitialised = true
147+
}
148+
149+
if !isRecipeInitialised {
150+
_, tppErr := thirdpartypasswordless.GetRecipeInstanceOrThrowError()
151+
152+
if tppErr == nil {
153+
isRecipeInitialised = true
154+
}
155+
}
134156
} else if recipeId == thirdparty.RECIPE_ID {
135157
_, err := thirdparty.GetRecipeInstanceOrThrowError()
136158

137-
return err == nil
159+
if err == nil {
160+
isRecipeInitialised = true
161+
}
162+
163+
if !isRecipeInitialised {
164+
_, tpepErr := thirdpartyemailpassword.GetRecipeInstanceOrThrowError()
165+
166+
if tpepErr == nil {
167+
isRecipeInitialised = true
168+
}
169+
}
138170
}
139171

140-
return false
172+
return isRecipeInitialised
141173
}

recipe/thirdpartyemailpassword/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestDefaultConfigForThirdPartyEmailPasswordRecipe(t *testing.T) {
5353
t.Error(err.Error())
5454
}
5555

56-
thirdpartyemailpassword, err := getRecipeInstanceOrThrowError()
56+
thirdpartyemailpassword, err := GetRecipeInstanceOrThrowError()
5757
if err != nil {
5858
t.Error(err.Error())
5959
}
@@ -112,7 +112,7 @@ func TestDefaultConfigForThirdPartyEmailPasswordRecipeWithProvider(t *testing.T)
112112
t.Error(err.Error())
113113
}
114114

115-
thirdpartyemailpassword, err := getRecipeInstanceOrThrowError()
115+
thirdpartyemailpassword, err := GetRecipeInstanceOrThrowError()
116116
if err != nil {
117117
t.Error(err.Error())
118118
}

recipe/thirdpartyemailpassword/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,79 +28,79 @@ func Init(config *tpepmodels.TypeInput) supertokens.Recipe {
2828
}
2929

3030
func ThirdPartySignInUpWithContext(thirdPartyID string, thirdPartyUserID string, email string, userContext supertokens.UserContext) (tpepmodels.SignInUpResponse, error) {
31-
instance, err := getRecipeInstanceOrThrowError()
31+
instance, err := GetRecipeInstanceOrThrowError()
3232
if err != nil {
3333
return tpepmodels.SignInUpResponse{}, err
3434
}
3535
return (*instance.RecipeImpl.ThirdPartySignInUp)(thirdPartyID, thirdPartyUserID, email, userContext)
3636
}
3737

3838
func GetUserByThirdPartyInfoWithContext(thirdPartyID string, thirdPartyUserID string, userContext supertokens.UserContext) (*tpepmodels.User, error) {
39-
instance, err := getRecipeInstanceOrThrowError()
39+
instance, err := GetRecipeInstanceOrThrowError()
4040
if err != nil {
4141
return nil, err
4242
}
4343
return (*instance.RecipeImpl.GetUserByThirdPartyInfo)(thirdPartyID, thirdPartyUserID, userContext)
4444
}
4545

4646
func EmailPasswordSignUpWithContext(email, password string, userContext supertokens.UserContext) (tpepmodels.SignUpResponse, error) {
47-
instance, err := getRecipeInstanceOrThrowError()
47+
instance, err := GetRecipeInstanceOrThrowError()
4848
if err != nil {
4949
return tpepmodels.SignUpResponse{}, err
5050
}
5151
return (*instance.RecipeImpl.EmailPasswordSignUp)(email, password, userContext)
5252
}
5353

5454
func EmailPasswordSignInWithContext(email, password string, userContext supertokens.UserContext) (tpepmodels.SignInResponse, error) {
55-
instance, err := getRecipeInstanceOrThrowError()
55+
instance, err := GetRecipeInstanceOrThrowError()
5656
if err != nil {
5757
return tpepmodels.SignInResponse{}, err
5858
}
5959
return (*instance.RecipeImpl.EmailPasswordSignIn)(email, password, userContext)
6060
}
6161

6262
func GetUserByIdWithContext(userID string, userContext supertokens.UserContext) (*tpepmodels.User, error) {
63-
instance, err := getRecipeInstanceOrThrowError()
63+
instance, err := GetRecipeInstanceOrThrowError()
6464
if err != nil {
6565
return nil, err
6666
}
6767
return (*instance.RecipeImpl.GetUserByID)(userID, userContext)
6868
}
6969

7070
func GetUsersByEmailWithContext(email string, userContext supertokens.UserContext) ([]tpepmodels.User, error) {
71-
instance, err := getRecipeInstanceOrThrowError()
71+
instance, err := GetRecipeInstanceOrThrowError()
7272
if err != nil {
7373
return nil, err
7474
}
7575
return (*instance.RecipeImpl.GetUsersByEmail)(email, userContext)
7676
}
7777

7878
func CreateResetPasswordTokenWithContext(userID string, userContext supertokens.UserContext) (epmodels.CreateResetPasswordTokenResponse, error) {
79-
instance, err := getRecipeInstanceOrThrowError()
79+
instance, err := GetRecipeInstanceOrThrowError()
8080
if err != nil {
8181
return epmodels.CreateResetPasswordTokenResponse{}, err
8282
}
8383
return (*instance.RecipeImpl.CreateResetPasswordToken)(userID, userContext)
8484
}
8585

8686
func ResetPasswordUsingTokenWithContext(token, newPassword string, userContext supertokens.UserContext) (epmodels.ResetPasswordUsingTokenResponse, error) {
87-
instance, err := getRecipeInstanceOrThrowError()
87+
instance, err := GetRecipeInstanceOrThrowError()
8888
if err != nil {
8989
return epmodels.ResetPasswordUsingTokenResponse{}, err
9090
}
9191
return (*instance.RecipeImpl.ResetPasswordUsingToken)(token, newPassword, userContext)
9292
}
9393

9494
func UpdateEmailOrPasswordWithContext(userId string, email *string, password *string, userContext supertokens.UserContext) (epmodels.UpdateEmailOrPasswordResponse, error) {
95-
instance, err := getRecipeInstanceOrThrowError()
95+
instance, err := GetRecipeInstanceOrThrowError()
9696
if err != nil {
9797
return epmodels.UpdateEmailOrPasswordResponse{}, err
9898
}
9999
return (*instance.RecipeImpl.UpdateEmailOrPassword)(userId, email, password, userContext)
100100
}
101101

102102
func SendEmailWithContext(input emaildelivery.EmailType, userContext supertokens.UserContext) error {
103-
instance, err := getRecipeInstanceOrThrowError()
103+
instance, err := GetRecipeInstanceOrThrowError()
104104
if err != nil {
105105
return err
106106
}

recipe/thirdpartyemailpassword/recipe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func recipeInit(config *tpepmodels.TypeInput) supertokens.Recipe {
141141
}
142142
}
143143

144-
func getRecipeInstanceOrThrowError() (*Recipe, error) {
144+
func GetRecipeInstanceOrThrowError() (*Recipe, error) {
145145
if singletonInstance != nil {
146146
return singletonInstance, nil
147147
}

recipe/thirdpartypasswordless/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestMinimumConfigForThirdPartyPasswordlessWithEmailOrPhoneContactMethod(t *
7979
return
8080
}
8181

82-
thirdPartyPasswordlessRecipe, err := getRecipeInstanceOrThrowError()
82+
thirdPartyPasswordlessRecipe, err := GetRecipeInstanceOrThrowError()
8383
assert.NoError(t, err)
8484
assert.Equal(t, "USER_INPUT_CODE_AND_MAGIC_LINK", thirdPartyPasswordlessRecipe.Config.FlowType)
8585
}
@@ -355,7 +355,7 @@ func TestWithThirdPartyPasswordLessMinimumConfigWithEmailContactMethod(t *testin
355355
return
356356
}
357357

358-
thirdPartyPasswordlessRecipe, err := getRecipeInstanceOrThrowError()
358+
thirdPartyPasswordlessRecipe, err := GetRecipeInstanceOrThrowError()
359359
assert.NoError(t, err)
360360
assert.Equal(t, "USER_INPUT_CODE_AND_MAGIC_LINK", thirdPartyPasswordlessRecipe.Config.FlowType)
361361
}

0 commit comments

Comments
 (0)