diff --git a/CHANGELOG.md b/CHANGELOG.md index 926da002..5941e1ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.17.0] - 2023-11-14 + +### Breaking change + +- Fixes github user id conversion to be consistent with other SDKs. + +### Migration + +If you were using the SDK Versions >= `0.13.0` and < `0.17.0`, use the following override function for github: + +```go +{ + Config: tpmodels.ProviderConfig{ + ThirdPartyId: "github", + // other config + }, + Override: func(originalImplementation *tpmodels.TypeProvider) *tpmodels.TypeProvider { + originalGetUserInfo := originalImplementation.GetUserInfo + originalImplementation.GetUserInfo = func(oAuthTokens tpmodels.TypeOAuthTokens, userContext supertokens.UserContext) (tpmodels.TypeUserInfo, error) { + userInfo, err := originalGetUserInfo(oAuthTokens, userContext) + if err != nil { + return userInfo, err + } + number, err := strconv.ParseFloat(userInfo.ThirdPartyUserId, 64) + if err != nil { + return userInfo, err + } + userInfo.ThirdPartyUserId = fmt.Sprint(number) + return userInfo, nil + } + + return originalImplementation + }, +}, +``` + +If you were using the SDK Versions < `0.13.0`, use the following override function for github: + +```go +{ + Config: tpmodels.ProviderConfig{ + ThirdPartyId: "github", + // other config + }, + Override: func(originalImplementation *tpmodels.TypeProvider) *tpmodels.TypeProvider { + originalGetUserInfo := originalImplementation.GetUserInfo + originalImplementation.GetUserInfo = func(oAuthTokens tpmodels.TypeOAuthTokens, userContext supertokens.UserContext) (tpmodels.TypeUserInfo, error) { + userInfo, err := originalGetUserInfo(oAuthTokens, userContext) + if err != nil { + return userInfo, err + } + number, err := strconv.ParseFloat(userInfo.ThirdPartyUserId, 64) + if err != nil { + return userInfo, err + } + userInfo.ThirdPartyUserId = fmt.Sprintf("%f", number) + return userInfo, nil + } + + return originalImplementation + }, +}, +``` + ## [0.16.6] - 2023-11-3 - Added `NetworkInterceptor` to the `ConnectionInfo` config. diff --git a/recipe/thirdparty/providers/github.go b/recipe/thirdparty/providers/github.go index 656cfdcc..74f026f4 100644 --- a/recipe/thirdparty/providers/github.go +++ b/recipe/thirdparty/providers/github.go @@ -135,7 +135,7 @@ func getSupertokensUserInfoFromRawUserInfoResponseForGithub(rawUserInfoResponse } result := tpmodels.TypeUserInfo{ - ThirdPartyUserId: fmt.Sprint(rawUserInfoResponse.FromUserInfoAPI["user"].(map[string]interface{})["id"]), + ThirdPartyUserId: fmt.Sprint(int64(rawUserInfoResponse.FromUserInfoAPI["user"].(map[string]interface{})["id"].(float64))), } emailsInfo := rawUserInfoResponse.FromUserInfoAPI["emails"].([]interface{}) diff --git a/supertokens/constants.go b/supertokens/constants.go index 43f0c522..88141066 100644 --- a/supertokens/constants.go +++ b/supertokens/constants.go @@ -21,7 +21,7 @@ const ( ) // VERSION current version of the lib -const VERSION = "0.16.6" +const VERSION = "0.17.0" var ( cdiSupported = []string{"3.0"}