---
name: "getCurrentUserSync"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "getCurrentUserSync - Get current user information."
summary: "Get current user information. This method can only be used after initialization."
---

## getCurrentUserSync

> [VERSION] @ray-js/lock-sdk >= 1.0.0

### Description

Synchronously read the current user from cache (no request is made).

### Parameters

None


### Return Value

Type: `CurrentUser`

Cached user or null

##### CurrentUser

| Property | Type | Description |
| --- | --- | --- |
| `userId` | `string` | Cloud user ID |
| `lockUserId` | `number` | Lock-side user ID |
| `userType` | `10 \| 20 \| 30 \| 40 \| 50` | User type (admin/regular, etc.) |
| `allOpenDps` | `string` | Encoded string of the DP set that supports remote unlocking |
| `allOpenType` | `number[]` | List of supported unlock method type IDs |
| `productAttribute` | `number` | Product attribute bits |
| `phase` | `number` | User status: 0 Frozen, 1 Normal, 5 Expired, 6 Not effective, 7 Deleted |
| `admin` | `boolean` | Is admin |
| `offlineUnlock` | `boolean` | Whether offline unlocking is allowed |
| `permanent` | `boolean` | Whether the user is permanently valid |
| `expireTime` | `number` | Expiration time (s) |
| `effectiveTime` | `number` | Activation time (s) |
| `expireDay` | `number` | Absolute expiration day count |

### Valid Values

##### `userType` valid values

| Value | Description |
| --- | --- |
| `10` | Admin
@descriptionEn Admin user |
| `20` | Regular member
@descriptionEn Normal household member |
| `30` | Anonymous
@descriptionEn Anonymous or unknown |
| `40` | Shared member
@descriptionEn Shared access user |
| `50` | Home owner
@descriptionEn Home owner |


### Examples

#### Example

```ts
import { getCurrentUserSync } from '@ray-js/lock-sdk';
const user = getCurrentUserSync();
```
