Skip to content

Commit a23cbb1

Browse files
authored
feat(user): add verifiedEmail and verifiedPhone filters to user search (#704)
1 parent 98b50f1 commit a23cbb1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,12 @@ usersRes.data.forEach((user) => {
867867

868868
// Search all users, optionally according to tenant and/or role filter
869869
// Results can be paginated using the limit and page parameters
870-
const usersRes = await descopeClient.management.user.search({ tenantIds: ['tenant-ID'] });
870+
// Additional filters: verifiedEmail, verifiedPhone, statuses, roles, tenantIds, etc.
871+
const usersRes = await descopeClient.management.user.search({
872+
tenantIds: ['tenant-ID'],
873+
verifiedEmail: true, // optional: filter by verified email status
874+
verifiedPhone: false, // optional: filter by verified phone status
875+
});
871876
console.log('Total users:', usersRes.data.total);
872877
usersRes.data.users.forEach((user) => {
873878
// do something

lib/management/user.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,29 @@ describe('Management User', () => {
11341134
response: httpResponse,
11351135
});
11361136
});
1137+
1138+
it('should pass verifiedEmail and verifiedPhone filters', async () => {
1139+
const httpResponse = {
1140+
ok: true,
1141+
json: () => mockMgmtUsersResponse,
1142+
clone: () => ({
1143+
json: () => Promise.resolve(mockMgmtUsersResponse),
1144+
}),
1145+
status: 200,
1146+
};
1147+
mockHttpClient.post.mockResolvedValue(httpResponse);
1148+
await management.user.search({
1149+
verifiedEmail: true,
1150+
verifiedPhone: false,
1151+
});
1152+
1153+
expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.user.search, {
1154+
verifiedEmail: true,
1155+
verifiedPhone: false,
1156+
roleNames: undefined,
1157+
roles: undefined,
1158+
});
1159+
});
11371160
});
11381161

11391162
describe('getProviderToken', () => {

lib/management/user.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ type SearchRequest = {
5959
toModifiedTime?: number; // Search users modified before this time (epoch in milliseconds)
6060
tenantRoleIds?: Record<string, RolesList>; // Search users based on tenants and role IDs
6161
tenantRoleNames?: Record<string, RolesList>; // Search users based on tenants and role names
62+
verifiedEmail?: boolean; // Filter by verified email status
63+
verifiedPhone?: boolean; // Filter by verified phone status
6264
};
6365

6466
type SingleUserResponse = {

0 commit comments

Comments
 (0)