Skip to content

Commit 202c7ee

Browse files
committed
chore: updated changelog
1 parent e323d4e commit 202c7ee

File tree

1 file changed

+140
-2
lines changed

1 file changed

+140
-2
lines changed

CHANGELOG.md

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Added `EmailVerificationClaim`.
1414
- `Mode` config is added to `evmodels.TypeInput`
1515
- `GetEmailForUserID` config is added to `evmodels.TypeInput`
16-
- Added `onInvalidClaim` optional error handler to send InvalidClaim error responses.
16+
- Added `OnInvalidClaim` optional error handler to send InvalidClaim error responses.
1717
- Added `INVALID_CLAIMS` to `SessionErrors`.
1818
- Added `InvalidClaimStatusCode` optional config to set the status code of InvalidClaim errors.
1919
- Added `OverrideGlobalClaimValidators` to options of `getSession` and `verifySession`.
@@ -42,7 +42,145 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4242
- `RefreshPOST` now returns a Session container object.
4343
- `SignOutPOST` now takes in an optional session object as a parameter.
4444
- `SessionContainer` is renamed to `TypeSessionContainer` and `SessionContainer` is now an alias for `*TypeSessionContainer`. All `*SessionContainer` is now replaced with `SessionContainer`.
45-
- `SendNon200Response` is renamed to `SendNon200ResponseWithMessage` and `SendNon200Response` takes in a body parameter.
45+
46+
### Migration
47+
48+
Before:
49+
50+
```go
51+
52+
supertokens.Init(supertokens.TypeInput{
53+
AppInfo: supertokens.AppInfo{
54+
AppName: "...",
55+
APIDomain: "...",
56+
WebsiteDomain: "...",
57+
},
58+
59+
RecipeList: []supertokens.Recipe{
60+
emailpassword.Init(&epmodels.TypeInput{
61+
EmailVerificationFeature: evmodels.TypeInput{
62+
// ...
63+
},
64+
Override: &epmodels.OverrideStruct{
65+
EmailVerificationFeature: &evmodels.OverrideStruct{
66+
// ...
67+
},
68+
},
69+
}),
70+
},
71+
})
72+
73+
```
74+
75+
After the update:
76+
77+
```go
78+
79+
supertokens.Init(supertokens.TypeInput{
80+
AppInfo: supertokens.AppInfo{
81+
AppName: "...",
82+
APIDomain: "...",
83+
WebsiteDomain: "...",
84+
},
85+
86+
RecipeList: []supertokens.Recipe{
87+
emailverification.Init(evmodels.TypeInput{
88+
// all config should be moved here from the emailVerificationFeature prop of the EmailPassword recipe config
89+
Override: &evmodels.OverrideStruct{
90+
// move the overrides from the emailVerificationFeature prop of the override config in the EmailPassword init here
91+
},
92+
}),
93+
emailpassword.Init(nil),
94+
},
95+
})
96+
97+
```
98+
99+
### Passwordless users and email verification
100+
101+
If you turn on email verification your email-based passwordless users may be redirected to an email verification screen in their existing session.
102+
Logging out and logging in again will solve this problem or they could click the link in the email to verify themselves.
103+
104+
You can avoid this by running a script that will:
105+
106+
1. list all users of passwordless
107+
2. create an emailverification token for each of them if they have email addresses
108+
3. user the token to verify their address
109+
110+
Something similar to this script:
111+
112+
```go
113+
package main
114+
115+
import (
116+
"github.com/supertokens/supertokens-golang/recipe/emailverification"
117+
"github.com/supertokens/supertokens-golang/recipe/emailverification/evmodels"
118+
"github.com/supertokens/supertokens-golang/recipe/passwordless"
119+
"github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels"
120+
"github.com/supertokens/supertokens-golang/recipe/session"
121+
"github.com/supertokens/supertokens-golang/supertokens"
122+
)
123+
124+
func main() {
125+
supertokens.Init(supertokens.TypeInput{
126+
AppInfo: supertokens.AppInfo{
127+
AppName: "...",
128+
APIDomain: "...",
129+
WebsiteDomain: "...",
130+
},
131+
132+
RecipeList: []supertokens.Recipe{
133+
emailverification.Init(evmodels.TypeInput{
134+
Mode: evmodels.ModeRequired,
135+
}),
136+
passwordless.Init(plessmodels.TypeInput{
137+
FlowType: "USER_INPUT_CODE_AND_MAGIC_LINK",
138+
ContactMethodEmailOrPhone: plessmodels.ContactMethodEmailOrPhoneConfig{
139+
Enabled: true,
140+
},
141+
}),
142+
session.Init(nil),
143+
},
144+
})
145+
146+
var paginationToken *string
147+
recipeList := []string{"passwordless"}
148+
limit := 100
149+
done := false
150+
151+
for !done {
152+
userList, err := supertokens.GetUsersNewestFirst(paginationToken, &limit, &recipeList)
153+
if err != nil {
154+
panic(err)
155+
}
156+
157+
for _, user := range userList.Users {
158+
if user.RecipeId == "passwordless" && user.User["email"] != nil {
159+
token, err := emailverification.CreateEmailVerificationToken(user.User["id"].(string), nil)
160+
if err != nil {
161+
panic(err)
162+
}
163+
if token.OK != nil {
164+
_, err := emailverification.VerifyEmailUsingToken(token.OK.Token)
165+
if err != nil {
166+
panic(err)
167+
}
168+
}
169+
}
170+
171+
done = (userList.NextPaginationToken == nil)
172+
paginationToken = userList.NextPaginationToken
173+
}
174+
}
175+
}
176+
```
177+
178+
#### User roles
179+
180+
The UserRoles recipe now adds role and permission information into the access token payload by default. If you are already doing this manually, this will result in duplicate data in the access token.
181+
182+
- You can disable this behaviour by setting `SkipAddingRolesToAccessToken` and `SkipAddingPermissionsToAccessToken` to true in the recipe init.
183+
- Check how to use the new claims in the updated guide: https://supertokens.com/docs/userroles/protecting-routes
46184

47185

48186
## [0.8.3] - 2022-07-30

0 commit comments

Comments
 (0)