Skip to content

Commit c079e94

Browse files
committed
makes remaining changes
1 parent cb383a9 commit c079e94

21 files changed

+1019
-33
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [unreleased]
99

1010

11+
## Breaking change
12+
13+
- Removed ThirdPartyEmailPassword and ThirdPartyPasswordless recipes. Instead, you should use ThirdParty + EmailPassword or ThirdParty + Passwordless recipes separately in your recipe list.
14+
- Removed `rid` query param from:
15+
- email verification links
16+
- passwordless magic links
17+
- password reset links
18+
19+
## Changes
20+
21+
- If `rid` header is present in an API call, the routing no only only depends on that. If the SDK cannot resolve a request handler based on the `rid`, request path and method, it will try to resolve a request handler only based on the request path and method (therefore ignoring the `rid` header).
22+
- New API handlers are:
23+
- `GET /emailpassword/email/exists` => email password, does email exist API (used to be `GET /signup/email/exists` with `rid` of `emailpassword` or `thirdpartyemailpassword` which is now deprecated)
24+
- `GET /passwordless/email/exists` => email password, does email exist API (used to be `GET /signup/email/exists` with `rid` of `passwordless` or `thirdpartypasswordless` which is now deprecated)
25+
- `GET /passwordless/phonenumber/exists` => email password, does email exist API (used to be `GET /signup/phonenumber/exists` which is now deprecated)
26+
- Support for FDI 2.0
27+
28+
## Migration guide
29+
30+
- If you were using `ThirdPartyEmailPassword`, you should now init `ThirdParty` and `EmailPassword` recipes separately. The config for the individual recipes are mostly the same, except the syntax may be different. Check our recipe guides for [ThirdParty](https://supertokens.com/docs/thirdparty/introduction) and [EmailPassword](https://supertokens.com/docs/emailpassword/introduction) for more information.
31+
32+
- If you were using `ThirdPartyPasswordless`, you should now init `ThirdParty` and `Passwordless` recipes separately. The config for the individual recipes are mostly the same, except the syntax may be different. Check our recipe guides for [ThirdParty](https://supertokens.com/docs/thirdparty/introduction) and [Passwordless](https://supertokens.com/docs/passwordless/introduction) for more information.
33+
34+
1135
## [0.17.5] - 2024-03-14
1236
- Adds a type uint64 to the `accessTokenCookiesExpiryDurationMillis` local variable in `recipe/session/utils.go`. It also removes the redundant `uint64` type forcing needed because of the untyped variable.
1337
- Fixes the passing of `tenantId` in `getAllSessionHandlesForUser` and `revokeAllSessionsForUser` based on `fetchAcrossAllTenants` and `revokeAcrossAllTenants` inputs respectively.

recipe/emailpassword/api/implementation.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func MakeAPIImplementation() epmodels.APIInterface {
6868

6969
passwordResetLink, err := GetPasswordResetLink(
7070
options.AppInfo,
71-
options.RecipeID,
7271
response.OK.Token,
7372
tenantId,
7473
options.Req,

recipe/emailpassword/api/utils.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,16 @@ func validateFormOrThrowError(configFormFields []epmodels.NormalisedFormField, i
126126
return nil
127127
}
128128

129-
func GetPasswordResetLink(appInfo supertokens.NormalisedAppinfo, recipeID string, token string, tenantId string, request *http.Request, userContext supertokens.UserContext) (string, error) {
129+
func GetPasswordResetLink(appInfo supertokens.NormalisedAppinfo, token string, tenantId string, request *http.Request, userContext supertokens.UserContext) (string, error) {
130130
websiteDomain, err := appInfo.GetOrigin(request, userContext)
131131
if err != nil {
132132
return "", err
133133
}
134134
return fmt.Sprintf(
135-
"%s%s/reset-password?token=%s&rid=%s&tenantId=%s",
135+
"%s%s/reset-password?token=%s&tenantId=%s",
136136
websiteDomain.GetAsStringDangerous(),
137137
appInfo.WebsiteBasePath.GetAsStringDangerous(),
138138
token,
139-
recipeID,
140139
tenantId,
141140
), nil
142141
}

recipe/emailpassword/authFlow_test.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,117 @@ import (
3232
"github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels"
3333
"github.com/supertokens/supertokens-golang/recipe/session"
3434
"github.com/supertokens/supertokens-golang/recipe/session/sessmodels"
35+
"github.com/supertokens/supertokens-golang/recipe/thirdparty"
36+
"github.com/supertokens/supertokens-golang/recipe/thirdparty/tpmodels"
3537
"github.com/supertokens/supertokens-golang/supertokens"
3638
"github.com/supertokens/supertokens-golang/test/unittesting"
3739
)
3840

41+
func TestRightRidButRecipeMissingReturns404(t *testing.T) {
42+
configValue := supertokens.TypeInput{
43+
Supertokens: &supertokens.ConnectionInfo{
44+
ConnectionURI: "http://localhost:8080",
45+
},
46+
AppInfo: supertokens.AppInfo{
47+
APIDomain: "api.supertokens.io",
48+
AppName: "SuperTokens",
49+
WebsiteDomain: "supertokens.io",
50+
},
51+
RecipeList: []supertokens.Recipe{
52+
thirdparty.Init(&tpmodels.TypeInput{
53+
SignInAndUpFeature: tpmodels.TypeInputSignInAndUp{
54+
Providers: []tpmodels.ProviderInput{
55+
{
56+
Config: tpmodels.ProviderConfig{
57+
ThirdPartyId: "google",
58+
Clients: []tpmodels.ProviderClientConfig{
59+
{
60+
ClientID: "4398792-test-id",
61+
ClientSecret: "test-secret",
62+
},
63+
},
64+
},
65+
},
66+
},
67+
},
68+
}),
69+
},
70+
}
71+
72+
BeforeEach()
73+
unittesting.StartUpST("localhost", "8080")
74+
defer AfterEach()
75+
err := supertokens.Init(configValue)
76+
if err != nil {
77+
t.Error(err.Error())
78+
}
79+
mux := http.NewServeMux()
80+
testServer := httptest.NewServer(supertokens.Middleware(mux))
81+
defer testServer.Close()
82+
83+
res, err := unittesting.SignInRequest("[email protected]", "validpass123", testServer.URL)
84+
85+
if err != nil {
86+
t.Error(err.Error())
87+
}
88+
89+
assert.NoError(t, err)
90+
assert.Equal(t, 404, res.StatusCode)
91+
}
92+
93+
func TestSignInWorksWithThirdPartyEmailPasswordRid(t *testing.T) {
94+
configValue := supertokens.TypeInput{
95+
Supertokens: &supertokens.ConnectionInfo{
96+
ConnectionURI: "http://localhost:8080",
97+
},
98+
AppInfo: supertokens.AppInfo{
99+
APIDomain: "api.supertokens.io",
100+
AppName: "SuperTokens",
101+
WebsiteDomain: "supertokens.io",
102+
},
103+
RecipeList: []supertokens.Recipe{
104+
thirdparty.Init(&tpmodels.TypeInput{
105+
SignInAndUpFeature: tpmodels.TypeInputSignInAndUp{
106+
Providers: []tpmodels.ProviderInput{
107+
{
108+
Config: tpmodels.ProviderConfig{
109+
ThirdPartyId: "google",
110+
Clients: []tpmodels.ProviderClientConfig{
111+
{
112+
ClientID: "4398792-test-id",
113+
ClientSecret: "test-secret",
114+
},
115+
},
116+
},
117+
},
118+
},
119+
},
120+
}),
121+
Init(nil),
122+
},
123+
}
124+
125+
BeforeEach()
126+
unittesting.StartUpST("localhost", "8080")
127+
defer AfterEach()
128+
err := supertokens.Init(configValue)
129+
if err != nil {
130+
t.Error(err.Error())
131+
}
132+
mux := http.NewServeMux()
133+
testServer := httptest.NewServer(supertokens.Middleware(mux))
134+
defer testServer.Close()
135+
136+
res, err := unittesting.SignInRequestWithThirdpartyemailpasswordRid("[email protected]", "validpass123", testServer.URL)
137+
138+
if err != nil {
139+
t.Error(err.Error())
140+
}
141+
142+
assert.NoError(t, err)
143+
assert.Equal(t, 200, res.StatusCode)
144+
}
145+
39146
// SigninFeature Tests
40147
func TestDisablingAPIDefaultSigninDoesNotWork(t *testing.T) {
41148
configValue := supertokens.TypeInput{

recipe/emailpassword/constants/constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ const (
2020
SignInAPI = "/signin"
2121
GeneratePasswordResetTokenAPI = "/user/password/reset/token"
2222
PasswordResetAPI = "/user/password/reset"
23-
SignupEmailExistsAPI = "/signup/email/exists"
23+
SignupEmailExistsAPIOld = "/signup/email/exists"
24+
SignupEmailExistsAPI = "/emailpassword/email/exists"
2425
)

0 commit comments

Comments
 (0)