Skip to content

Commit

Permalink
Merge pull request #388 from supertokens/github-fix
Browse files Browse the repository at this point in the history
fix: github userid conversion
  • Loading branch information
rishabhpoddar authored Nov 14, 2023
2 parents 7632d2f + 1fac98e commit ac39010
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion recipe/thirdparty/providers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
2 changes: 1 addition & 1 deletion supertokens/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down

0 comments on commit ac39010

Please sign in to comment.