## Member Management

Door lock member management relies on the App's family member management functionality. Based on this, unlock method management can be performed for members. Supported capabilities include:
- Get member list, supporting returning member names, accounts, roles, and unlock method lists;
- Invite members to join the family
- View, edit, and delete family members
- Add regular members
- Delete regular members

### Supported Roles
- Administrator: Family administrator with the highest management permissions for the lock, can perform all operations.
- Member: Can view information related to themselves, such as: unlock records, certain settings, etc.
- Regular Member: No account, cannot enter the panel

> Administrators and members need to be invited to join the family, while regular members need to be added through the [Add Regular Member API]


### API

#### Get Member List

- Meaning: Get the member list under the current lock, including family administrators and family members. When the lock supports large-capacity unlock methods, regular members will also be returned.
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/user/getUsers)

#### Get Family Member Detailed Information

- Meaning: Get detailed family member information, including name, account, role, unlock method list, etc.
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/user/getUserInfo)

#### Add Regular Member

- Meaning: When the lock supports large-capacity unlock methods, regular members without accounts can be added to manage this member's unlock methods.
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/user/addUser)

#### Delete Regular Member

- Meaning: When the lock supports large-capacity unlock methods, regular members can be deleted through this method.
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/user/removeUser)

#### Update Non-Administrator Role Validity Period

- Meaning: This API can be used to fix the validity period of members with non-administrator roles. The member's validity period will affect the validity period of the member's unlock methods.
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/user/updateUserLimitTime)


## FAQ

### Q1: How to distinguish administrators and regular members?

**A:** Determine by the `userType` field:
```typescript
import { UserType } from '@ray-js/lock-sdk';

const adminList = members.filter(
  item => item.userType === UserType.ADMIN || item.userType === UserType.OWNER
);
const memberList = members.filter(
  item => item.userType !== UserType.ADMIN && item.userType !== UserType.OWNER
);
```

### Q2: What to do if adding a member fails?

**A:** Check:
1. Member name cannot be empty
2. If the lock uses a small-capacity solution, it is not recommended to use the `addUser` API

### Q3: How to set member validity period?

**A:** Use the `updateUserLimitTime` API:
- `permanent: true` means permanently valid
- `permanent: false` requires providing an `effective` configuration object

### Q4: What are unbound unlock methods?

**A:** Unbound unlock methods refer to unlock methods that have been recorded on the device but are not associated with users (such as fingerprints, faces, etc.). They can be checked through `checkUnBindUnlockMethods` and associated with users through the binding function.

### Q5: How to sync unlock methods?

**A:** Call the `syncUnlockMethod()` method, which will sync data between the device and the cloud.

### Q6: Does the member list support pagination?

**A:** Yes, controlled through `page` and `pageSize` parameters:
```typescript
const result = await getUsers({ page: 1, pageSize: 50 });
if (result.hasMore) {
  // Load next page
}
```

### Q7: How to search for members?

**A:** Use the `keyword` parameter:
```typescript
const result = await getUsers({ keyword: 'search keyword' });
```

### Q8: Will deleting a member also delete their unlock methods?

**A:** Yes, both the member and their associated unlock methods will be deleted.