-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #383 from supertokens/dashboard-no-users-fix
fix: Fix issue of dashboard showing no user found for thirdparty users with thirdpartypasswordless
- Loading branch information
Showing
7 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,13 @@ package dashboard | |
|
||
import ( | ||
"encoding/json" | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard/api" | ||
"github.com/supertokens/supertokens-golang/recipe/dashboard/api/userdetails" | ||
"github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels" | ||
"github.com/supertokens/supertokens-golang/recipe/session" | ||
"github.com/supertokens/supertokens-golang/recipe/thirdparty/tpmodels" | ||
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless" | ||
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless/tplmodels" | ||
"io" | ||
"net/http" | ||
"net/http/httptest" | ||
|
@@ -79,3 +85,77 @@ func TestThatUserGetReturnsTenantIDsCorrectly(t *testing.T) { | |
assert.True(t, len(response.User.TenantIds) > 0) | ||
assert.Equal(t, response.User.TenantIds[0], "public") | ||
} | ||
|
||
func TestThatUserGetReturnsValidUserForThirdPartyUserWhenUsingThirdPartyPasswordless(t *testing.T) { | ||
config := supertokens.TypeInput{ | ||
Supertokens: &supertokens.ConnectionInfo{ | ||
ConnectionURI: "http://localhost:8080", | ||
}, | ||
AppInfo: supertokens.AppInfo{ | ||
APIDomain: "api.supertokens.io", | ||
AppName: "SuperTokens", | ||
WebsiteDomain: "supertokens.io", | ||
}, | ||
RecipeList: []supertokens.Recipe{ | ||
thirdpartypasswordless.Init(tplmodels.TypeInput{ | ||
FlowType: "USER_INPUT_CODE_AND_MAGIC_LINK", | ||
ContactMethodEmailOrPhone: plessmodels.ContactMethodEmailOrPhoneConfig{ | ||
Enabled: true, | ||
}, | ||
Providers: []tpmodels.ProviderInput{ | ||
thirdpartypasswordless.SigninupCustomProvider1, | ||
}, | ||
}), | ||
Init(&dashboardmodels.TypeInput{ | ||
ApiKey: "testapikey", | ||
}), | ||
session.Init(nil), | ||
}, | ||
} | ||
|
||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
err := supertokens.Init(config) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
mux := http.NewServeMux() | ||
testServer := httptest.NewServer(supertokens.Middleware(mux)) | ||
defer testServer.Close() | ||
|
||
_, err = unittesting.SigninupCustomRequest(testServer.URL, "[email protected]", "testPass0") | ||
|
||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
req, err := http.NewRequest(http.MethodGet, testServer.URL+"/auth/dashboard/api/users?limit=10", strings.NewReader(`{}`)) | ||
req.Header.Set("Authorization", "Bearer testapikey") | ||
res, err := http.DefaultClient.Do(req) | ||
|
||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
var listResponse api.UsersGetResponse | ||
body, _ := io.ReadAll(res.Body) | ||
json.Unmarshal(body, &listResponse) | ||
|
||
user := listResponse.Users[0].User | ||
|
||
req, err = http.NewRequest(http.MethodGet, testServer.URL+"/auth/dashboard/api/user?userId="+user.Id+"&recipeId=thirdparty", strings.NewReader(`{}`)) | ||
req.Header.Set("Authorization", "Bearer testapikey") | ||
res, err = http.DefaultClient.Do(req) | ||
|
||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
|
||
var response userdetails.UserGetResponse | ||
body, _ = io.ReadAll(res.Body) | ||
json.Unmarshal(body, &response) | ||
|
||
assert.Equal(t, response.Status, "OK") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters