From 8d85e77c0f22fe22a29706b36a77133bc36c8687 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 14 Nov 2023 12:44:38 +0530 Subject: [PATCH 1/3] fix: github userid conversion --- recipe/thirdparty/providers/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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{}) From 682d3a7d9619d21142af677ae0b87ac1a2eae633 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 14 Nov 2023 13:07:59 +0530 Subject: [PATCH 2/3] fix: version update --- CHANGELOG.md | 4 ++++ supertokens/constants.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926da002..c21d1574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.16.7] - 2023-11-14 + +- Fixes issue with github user id conversion + ## [0.16.6] - 2023-11-3 - Added `NetworkInterceptor` to the `ConnectionInfo` config. diff --git a/supertokens/constants.go b/supertokens/constants.go index 43f0c522..86d789de 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.16.7" var ( cdiSupported = []string{"3.0"} From 1fac98e9d20975077b923f6298ff3a0805df04e5 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 14 Nov 2023 13:34:14 +0530 Subject: [PATCH 3/3] fix: updated version and changelog --- CHANGELOG.md | 64 ++++++++++++++++++++++++++++++++++++++-- supertokens/constants.go | 2 +- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c21d1574..5941e1ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,69 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] -## [0.16.7] - 2023-11-14 +## [0.17.0] - 2023-11-14 -- Fixes issue with github user id conversion +### 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 diff --git a/supertokens/constants.go b/supertokens/constants.go index 86d789de..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.7" +const VERSION = "0.17.0" var ( cdiSupported = []string{"3.0"}