# Manage users

Authing management module.

This module can perform operations such as adding, deleting, modifying and querying user directories, searching for users, refreshing user tokens, managing user groups, managing user roles, and managing user policy authorization.

# Create user

UsersManagementClient().create(userInfo)

This interface will create a user as an administrator and does not require security checks such as mobile phone number verification code verification.

# Parameters

  • userInfo <CreateUserInput> user information
  • userInfo.email <string> mailbox, the only one in the user pool
  • userInfo.emailVerified <boolean> Is the email verified?
  • userInfo.phone <string> phone number
  • userInfo.phoneVerified <boolean> Whether the phone number is verified
  • userInfo.unionid <string> For users who log in as social, this field is the unique ID of the user in the third-party social login service provider
  • userInfo.openid <string> openid returned by WeChat login
  • userInfo.password <string> password
  • userInfo.registerSource <string> Registration source, you can select multiple
  • userInfo.username <string> username
  • userInfo.nickname <string> nickname
  • userInfo.photo <string> Avatar
  • userInfo.company <string> company
  • userInfo.browser <string> browser
  • userInfo.loginsCount <number> Number of logins, this field can be set when you migrate from the original user system to Authing.
  • userInfo.lastLogin <string> Last login time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")
  • userInfo.lastIP <string> The IP of the user's last login (or other activity)
  • userInfo.signedUp <string> Registration time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")
  • userInfo.blocked <boolean> whether the account is disabled
  • userInfo.isDeleted <boolean> mark whether the account is deleted
  • userInfo.device <string> device
  • userInfo.lastIP <string> Last logged in IP
  • userInfo.name <string> Name
  • userInfo.givenName <string> Given Name
  • userInfo.familyName <string> Family Name
  • userInfo.middleName <string> Middle Name
  • userInfo.profile <string> Profile Url
  • userInfo.preferredUsername <string> Preferred Name
  • userInfo.website <string> personal website
  • userInfo.gender <string> gender, M stands for male, W stands for female, and U stands for unknown.
  • userInfo.birthdate <string> birthday
  • userInfo.zoneinfo <string> time zone
  • userInfo.locale <string> language
  • userInfo.address <string> address
  • userInfo.streetAddress <string> street address
  • userInfo.locality <string>
  • userInfo.region <string> region
  • userInfo.postalCode <string> Zip code
  • userInfo.city <string> city
  • userInfo.province <string> province
  • userInfo.country <string> country

# Example

$email = "test@example.com";
$password = '123456';
$user = $managementClient->users()->create((new CreateUserInput())->withEmail($email)->withPassword($password));

# Modify user information

UsersManagementClient *().update(id, updates)

Modify user information

# Parameters

  • id <string> User ID
  • updates <UpdateUserInput> modified user profile
  • updates.email <string> Email
  • updates.emailVerified <boolean> Is the email verified?
  • updates.phone <string> phone number
  • updates.phoneVerified <boolean> Whether the phone number is verified
  • updates.unionid <string> For users who log in socially, this field is the user's unique ID in the third-party social login service provider
  • updates.openid <string> openid returned by WeChat login
  • updates.password <string> password
  • updates.registerSource <string> Registration source, you can select multiple
  • updates.tokenExpiredAt <string> token expiration time, a time string conforming to the ISO8601 format. (Such as "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00"). Setting this field to be less than the current time can invalidate the user's token.
  • updates.username <string> username
  • updates.nickname <string> nickname
  • updates.photo <string> Avatar
  • updates.company <string> company
  • updates.browser <string> browser
  • updates.loginsCount <number> Number of logins, this field can be set when you migrate from the original user system to Authing.
  • updates.lastLogin <string> Last login time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")
  • updates.lastIP <string> The IP of the user's last login (or other activity)
  • updates.signedUp <string> Registration time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")
  • updates.blocked <boolean> whether the account is disabled
  • updates.device <string> device
  • updates.lastIP <string> Last logged in IP
  • updates.name <string> Name
  • updates.givenName <string> Given Name
  • updates.familyName <string> Family Name
  • updates.middleName <string> Middle Name
  • updates.profile <string> Profile Url
  • updates.preferredUsername <string> Preferred Name
  • updates.website <string> personal website
  • updates.gender <string> gender, M stands for male, W stands for female, and U stands for unknown.
  • updates.birthdate <string> birthday
  • updates.zoneinfo <string> time zone
  • updates.locale <string> language
  • updates.address <string> address
  • updates.streetAddress <string> street address
  • updates.locality <string>
  • updates.region <string> region
  • updates.postalCode <string> Zip code
  • updates.city <string> city
  • updates.province <string> province
  • updates.country <string> country

# Example

# Get user details

UsersManagementClient().detail(userId)

Get user details by user ID. If you want to get user details by token, please use AuthenticationClient SDK.

# Parameters

  • userId <string> user ID

# Example

$user = $managementClient->users()->detail("userId");

# delete users

UsersManagementClient().delete(userId)

Delete user

# Parameters

  • userId <string> user ID

# Example

$message = $managementClient->users()->delete("userId");

# Delete users in batch

UsersManagementClient().deleteMany(userIds)

Batch delete users

# Parameters

  • userIds <string[]> list of user IDs

# Example

$message = $managementClient->users()->deleteMany(["userId"]);

# Get users in batch

UsersManagementClient().batch(userIds)

Get user details in batches by ID

# Parameters

  • userIds <string[]> list of user IDs

# Example

$users = $managementClient->users()->batch(["userId"]);

# Get user list

UsersManagementClient().list(page, limit)

Get user pool user list

# Parameters

  • page <number> Page number, starting from 1 The default value is: 1.
  • limit <number> The number of users included in each page The default value is 10.

# Example

$users = $managementClient->users()->paginate();

# Find users

UsersManagementClient().find(options)

Find users by username, email, mobile phone number

# Parameters

  • options <Object>
  • options.username <string> User name, case sensitive.
  • options.email <string> mailbox, the mailbox is not case sensitive.
  • options.phone <string> phone number

# Example

# Search users

UsersManagementClient().search(query, options, page, limit)

Search users based on keywords

# Parameters

  • query <null> search content
  • options <string[]> options
  • options.fields <string[]> Search user fields, if not specified, the default will be fuzzy search from username, nickname, email, phone, company, name, givenName, familyName, middleName, profile, preferredUsername fields . If you need precise search, please use the find method.
  • page <number> The default value is: 1.
  • limit <number> The default value is 10.

# Example

$users = $managementClient->users()->search("query");

# Refresh user token

UsersManagementClient().refreshToken(id)

Refresh user token

# Parameters

  • id <string> User ID

# Example

$message = $managementClient->users()->refreshToken("userId");

# Get user group list

UsersManagementClient().listGroups(userId)

Get user group list

# Parameters

  • userId <string> user ID

# Example

$list = $managementClient->users()->listGroups("userId");

# Join group

UsersManagementClient().addGroup(userId, group)

Add users to groups

# Parameters

  • userId <string> user ID
  • group <string> group code

# Example

$managementClient->users()->addGroup("userId", "group code");

# Exit group

UsersManagementClient().removeGroup(userId, group)

Exit group

# Parameters

  • userId <string> user ID
  • group <string> group code

# Example

$managementClient->users()->removeGroup("userId", "group code");

# Get user role list

UsersManagementClient().listRoles(userId)

Get the user's role list

# Parameters

  • userId <string> user ID

# Example

$roles = $managementClient->users()->listRoles("userId");

# Add role

UsersManagementClient().addRoles(userId, roles)

Add users to roles

# Parameters

  • userId <string> user ID
  • roles <string> role code list

# Example

$managementClient->users()->addRoles("userId", ["role code"]);

# Remove role

UsersManagementClient().removeRoles(userId, roles)

Remove user from role

# Parameters

  • userId <string> user ID
  • roles <string> role code list

# Example

$message = $managementClient->users()->removeRoles("userId", ["role code"]);