Skip to content

Commit

Permalink
update user methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisintech committed Jul 5, 2024
1 parent 5806921 commit 8c0b432
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 84 deletions.
12 changes: 6 additions & 6 deletions docs/references/backend/user/ban-user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ function banUser: (userId: string) => Promise<User>;
## Example

```tsx {13}
const userId = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56';
const userId = 'user_123;

const response = await clerkClient.users.banUser(userId);

console.log(response);
/*
_User {
id: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56',
id: 'user_123,
passwordEnabled: false,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: true,
createdAt: 1694181111181,
updatedAt: 1708101775581,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yVjdKSkhvdXlnbDNLRXRaUjlRRlFNbnVDU2cuanBlZyJ9',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
primaryEmailAddressId: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
primaryEmailAddressId: 'idn_123',
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: 1708101739595,
Expand All @@ -52,7 +52,7 @@ _User {
unsafeMetadata: {},
emailAddresses: [
_EmailAddress {
id: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
id: 'idn_123',
emailAddress: '[email protected]',
verification: [_Verification],
linkedTo: [Array]
Expand All @@ -62,7 +62,7 @@ _User {
web3Wallets: [],
externalAccounts: [
_ExternalAccount {
id: 'idn_2V7JJ4xpXyj0mazg3lsLYOUit9t',
id: 'idn_123',
provider: undefined,
identificationId: undefined,
externalId: undefined,
Expand Down
4 changes: 2 additions & 2 deletions docs/references/backend/user/delete-user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ function deleteUser: (userId: string) => Promise<User>;
## Example

```tsx
const userId = 'user_2b8lKxzUgn5M1hsjaTW1mcjc0iB';
const userId = 'user_123';

const response = await clerkClient.users.deleteUser(userId);

console.log(response);
/*
_DeletedObject {
object: 'user',
id: 'user_2b8kQleSRNmcOSCdJ1Y8pSRr4mK',
id: 'user_123',
slug: null,
deleted: true
}
Expand Down
4 changes: 2 additions & 2 deletions docs/references/backend/user/disable-user-mfa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function disableUserMFA: (userId: string) => Promise<User>;
## Example

```tsx
const userId = 'user_2bxfCJOe0Ocd8DNe9hFN3EXvfOu';
const userId = 'user_123';

const response = await clerkClient.users.disableUserMFA(userId);

console.log(response);
/*
{ user_id: 'user_2bxfCJOe0Ocd8DNe9hFN3EXvfOu' }
{ user_id: 'user_123' }
*/
```

Expand Down
4 changes: 2 additions & 2 deletions docs/references/backend/user/get-count.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ The total count of users can be filtered down by adding one or more of these par
| --- | --- | --- |
| `emailAddress?` | `string[]` | The email addresses to filter by. |
| `phoneNumber?` | `string[]` | The phone numbers to filter by. |
| `externalId?` | `string[]` | The external ID's to filter by. |
| `username?` | `string[]` | The usernames to filter by. |
| `web3wallet?` | `string[]` | The web3wallet to filter by. |
| `query?` | `string` | A search query to filter users by. |
| `userId?` | `string` | The user ID's to filter by. |
| `externalId?` | `string[]` | The external ID's to filter by. |
| `query?` | `string` | Counts users that match the given query. For possible matches, we check the email addresses, phone numbers, usernames, web3 wallets, user ids, first and last names. The query value doesn't need to match the exact value you are looking for, it is capable of partial matches as well. |

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getOrganizationMembershipList: (params: GetOrganizationMembershipListPa
In this example, you can see that the returned [`PaginatedResourceResponse`](/docs/references/backend/types/paginated-resource-response) includes `data`, which is an array of [`OrganizationMembership`](/docs/references/javascript/organization-membership) objects, and `totalCount`, which indicates the total number of organization memberships in the system for the specified organization.

```tsx
const userId = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56';
const userId = 'user_123';

const response = await clerkClient.users.getOrganizationMembershipList({ userId });

Expand All @@ -37,7 +37,7 @@ console.log(response);
{
data: [
_OrganizationMembership {
id: 'orgmem_2bjJ8KfbbOyzmF4wMRU7kjHvsgI',
id: 'orgmem_123',
role: 'org:admin',
publicMetadata: {},
privateMetadata: {},
Expand All @@ -47,7 +47,7 @@ console.log(response);
publicUserData: [_OrganizationMembershipPublicUserData]
},
_OrganizationMembership {
id: 'orgmem_2bjJ4JMtzPQIBRWQqeFKdJ0fg1s',
id: 'orgmem_456',
role: 'org:admin',
publicMetadata: {},
privateMetadata: {},
Expand Down
20 changes: 10 additions & 10 deletions docs/references/backend/user/get-user-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ console.log(response);
{
data: [
_User {
id: 'user_2cAkrFJNEmOVuKQqLbKbj2glKcu',
id: 'user_123',
passwordEnabled: false,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: false,
createdAt: 1707561967007,
updatedAt: 1707561967095,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yY0Frckh3dWtza1NmYXhIajRLakNEbndJS2EifQ',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
primaryEmailAddressId: 'idn_2cAkqw5hh4hN9AFYllNKSkJZZxu',
primaryEmailAddressId: 'idn_123',
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: 1707561967014,
externalId: null,
username: null,
firstName: 'Vyacheslav',
lastName: 'Ogai',
firstName: 'First',
lastName: 'Test',
publicMetadata: {},
privateMetadata: {},
unsafeMetadata: {},
Expand All @@ -76,24 +76,24 @@ console.log(response);
createOrganizationEnabled: true
},
_User {
id: 'user_2cA1W52mI9k31aomHIZm5udQD6t',
id: 'user_456',
passwordEnabled: false,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: false,
createdAt: 1707539597250,
updatedAt: 1707539597331,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yY0ExVzRIM0o0Uk9EaGx6ZTcyTkhSRHc0TEwifQ',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
primaryEmailAddressId: 'idn_2cA1W2G13Ke5SxfXeftcdZUbd1F',
primaryEmailAddressId: 'idn_456',
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: 1707539597260,
externalId: null,
username: null,
firstName: 'Noah',
lastName: 'Moscovici',
firstName: 'Second',
lastName: 'Test',
publicMetadata: {},
privateMetadata: {},
unsafeMetadata: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getUserOauthAccessToken: (userId: string, provider: `oauth_${OAuthProvi
## Example

```tsx
const userId = 'user_2bxfCJOe0Ocd8DNe9hFN3EXvfOu';
const userId = 'user_123';

const provider = 'oauth_google';

Expand Down
10 changes: 5 additions & 5 deletions docs/references/backend/user/get-user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ function getUser: (userId: string) => Promise<User>;
## Example

```tsx
const userId = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56';
const userId = 'user_123';

const response = await clerkClient.users.getUser(userId);

console.log(response);
/*
_User {
id: 'user_2cSSCzV7948rhPJMsY601tXsEU4',
id: 'user_123',
passwordEnabled: true,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: false,
createdAt: 1708103362688,
updatedAt: 1708103362701,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoiZGVmYXVsdCIsImlpZCI6Imluc18yVjdKRFdyclJwRmZFZTlqQUM2dWpSMG8xSlQiLCJyaWQiOiJ1c2VyXzJjU1NDelY3OTQ4cmhQSk1zWTYwMXRYc0VVNCIsImluaXRpYWxzIjoiVFUifQ',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: false,
primaryEmailAddressId: 'idn_2cSSCuFhU35F5u5Labwtmj7xU6B',
primaryEmailAddressId: 'idn_123',
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: null,
Expand All @@ -52,7 +52,7 @@ _User {
unsafeMetadata: {},
emailAddresses: [
_EmailAddress {
id: 'idn_2cSSCuFhU35F5u5Labwtmj7xU6B',
id: 'idn_123',
emailAddress: '[email protected]',
verification: [_Verification],
linkedTo: []
Expand Down
12 changes: 6 additions & 6 deletions docs/references/backend/user/lock-user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ function lockUser: (userId: string) => Promise<User>;
## Example

```tsx {13}
const userId = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56';
const userId = 'user_123';

const response = await clerkClient.users.lockUser(userId);

console.log(response);
/*
_User {
id: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56',
id: 'user_123',
passwordEnabled: false,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: false,
createdAt: 1694181111181,
updatedAt: 1708102548373,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yVjdKSkhvdXlnbDNLRXRaUjlRRlFNbnVDU2cuanBlZyJ9',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
primaryEmailAddressId: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
primaryEmailAddressId: 'idn_123',
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: 1708101739595,
Expand All @@ -54,7 +54,7 @@ _User {
unsafeMetadata: {},
emailAddresses: [
_EmailAddress {
id: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
id: 'idn_123',
emailAddress: '[email protected]',
verification: [_Verification],
linkedTo: [Array]
Expand All @@ -64,7 +64,7 @@ _User {
web3Wallets: [],
externalAccounts: [
_ExternalAccount {
id: 'idn_2V7JJ4xpXyj0mazg3lsLYOUit9t',
id: 'idn_123',
provider: undefined,
identificationId: undefined,
externalId: undefined,
Expand Down
12 changes: 6 additions & 6 deletions docs/references/backend/user/unban-user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ function unbanUser: (userId: string) => Promise<User>;
## Example

```tsx {13}
const userId = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56';
const userId = 'user_123';

const response = await clerkClient.users.unbanUser(userId);

console.log(response);
/*
_User {
id: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56',
id: 'user_123',
passwordEnabled: false,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: false,
createdAt: 1694181111181,
updatedAt: 1708102137929,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yVjdKSkhvdXlnbDNLRXRaUjlRRlFNbnVDU2cuanBlZyJ9',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
primaryEmailAddressId: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
primaryEmailAddressId: 'idn_123',
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: 1708101739595,
Expand All @@ -52,7 +52,7 @@ _User {
unsafeMetadata: {},
emailAddresses: [
_EmailAddress {
id: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
id: 'idn_123',
emailAddress: '[email protected]',
verification: [_Verification],
linkedTo: [Array]
Expand All @@ -62,7 +62,7 @@ _User {
web3Wallets: [],
externalAccounts: [
_ExternalAccount {
id: 'idn_2V7JJ4xpXyj0mazg3lsLYOUit9t',
id: 'idn_123',
provider: undefined,
identificationId: undefined,
externalId: undefined,
Expand Down
12 changes: 6 additions & 6 deletions docs/references/backend/user/unlock-user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ function unlockUser: (userId: string) => Promise<User>;
## Example

```tsx {13}
const userId = 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56';
const userId = 'user_123';

const response = await clerkClient.users.unlockUser(userId);

console.log(response);
/*
_User {
id: 'user_2V7JJKmoA9HqzHhfMqK5cpgLl56',
id: 'user_123',
passwordEnabled: false,
totpEnabled: false,
backupCodeEnabled: false,
twoFactorEnabled: false,
banned: false,
createdAt: 1694181111181,
updatedAt: 1708102548373,
imageUrl: 'https://img.clerk.com/eyJ0eXBlIjoicHJveHkiLCJzcmMiOiJodHRwczovL2ltYWdlcy5jbGVyay5kZXYvb2F1dGhfZ29vZ2xlL2ltZ18yVjdKSkhvdXlnbDNLRXRaUjlRRlFNbnVDU2cuanBlZyJ9',
imageUrl: 'https://img.clerk.com/eyJ...',
hasImage: true,
primaryEmailAddressId: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
primaryEmailAddressId: 'idn_123,
primaryPhoneNumberId: null,
primaryWeb3WalletId: null,
lastSignInAt: 1708101739595,
Expand All @@ -52,7 +52,7 @@ _User {
unsafeMetadata: {},
emailAddresses: [
_EmailAddress {
id: 'idn_2V7JJ2R3O7KWHjCmUuEOJESHlPz',
id: 'idn_123,
emailAddress: '[email protected]',
verification: [_Verification],
linkedTo: [Array]
Expand All @@ -62,7 +62,7 @@ _User {
web3Wallets: [],
externalAccounts: [
_ExternalAccount {
id: 'idn_2V7JJ4xpXyj0mazg3lsLYOUit9t',
id: 'idn_123',
provider: undefined,
identificationId: undefined,
externalId: undefined,
Expand Down
Loading

0 comments on commit 8c0b432

Please sign in to comment.