# GC.Spread.Common.UserManager

## Content

# Class: UserManager

[Spread](../modules/GC.Spread).[Common](../modules/GC.Spread.Common).UserManager

## Table of contents

### Constructors

- [constructor](GC.Spread.Common.UserManager#constructor)

### Methods

- [bind](GC.Spread.Common.UserManager#bind)
- [configure](GC.Spread.Common.UserManager#configure)
- [current](GC.Spread.Common.UserManager#current)
- [get](GC.Spread.Common.UserManager#get)
- [unbind](GC.Spread.Common.UserManager#unbind)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new UserManager**()

Represent a user manager.

## Methods

### <a id="bind" name="bind"></a> bind

▸ `Static` **bind**(`event`, `handler`): `void`

Bind an event handler.

**`static`**

**`example`**
```javascript
const users = spread.users;
users.bind(GC.Spread.Common.Events.CurrentUserChanged, (event, args) => {
    console.log(event);
    console.log(args.oldCurrentUser);
    console.log(args.newCurrentUser);
});
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `event` | [`Events`](GC.Spread.Common.Events) | Event type. |
| `handler` | `Function` | Event handler. |

#### Returns

`void`

___

### <a id="configure" name="configure"></a> configure

▸ `Static` **configure**(`options`): `void`

Configure the user manager options.

**`static`**

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `options` | [`IUserManagerOptions`](../interfaces/GC.Spread.Common.IUserManagerOptions) | The user manager options. |

#### Returns

`void`

___

### <a id="current" name="current"></a> current

▸ `Static` **current**(`userId?`): `undefined` \| `string`

Get or set the current user.

**`static`**

**`example`**
```javascript
// navigate from the login page, and get the login user id
spread.users.current('715CFB19-2BB9-4B94-BE0C-08D0F9A019D4'); // { id: "715CFB19-2BB9-4B94-BE0C-08D0F9A019D4", name: "John Doe" }
console.log(spread.users.getSync(spread.users.current()).name); // "John Doe"
```

#### Parameters

| Name | Type |
| :------ | :------ |
| `userId?` | `string` |

#### Returns

`undefined` \| `string`

The current user id.

___

### <a id="get" name="get"></a> get

▸ `Static` **get**(`userId`): `Promise`<`undefined` \| [`IUser`](../interfaces/GC.Spread.Common.IUser)\>

Get a user by user id.

**`static`**

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `userId` | `string` | The user id. |

#### Returns

`Promise`<`undefined` \| [`IUser`](../interfaces/GC.Spread.Common.IUser)\>

The user.

___

### <a id="unbind" name="unbind"></a> unbind

▸ `Static` **unbind**(`event`, `handler`): `void`

Unbind an event handler.

**`static`**

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `event` | [`Events`](GC.Spread.Common.Events) | Event type. |
| `handler` | `Function` | Event handler. |

#### Returns

`void`
