# User

## AV. User

An AV.User object is a local representation of a user persisted to the LeanCloud server. This class is a subclass of an AV.Object, and retains the same functionality of an AV.Object, but also extends it with various user specific methods, like authentication, signing up, and validation of uniqueness.

## Constructor

#### new User()

Source:
  - user.js, line 67

### Methods

#### (static) become(sessionToken) → {Promise}

Source:
  - user.js, line 927

Logs in a user with a session token. On success, this saves the session to disk, so you can retrieve the currently logged in user using `current`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`sessionToken` | String | The sessionToken to log in with.

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) current() → {AV.User}

Source:
  - user.js, line 1451

Retrieves the currently logged in AVUser with a valid session, either from memory or localStorage, if necessary.

##### Returns:

The currently logged in AV.User.

Type
  AV.User

#### (static) currentAsync() → {Promise.<AV.User>}

Source:
  - user.js, line 1402

Retrieves the currently logged in AVUser with a valid session, either from memory or localStorage, if necessary.

##### Returns:

resolved with the currently logged in AV.User.

Type
  Promise.<AV.User>

#### (static) followeeQuery(userObjectId) → {AV.FriendShipQuery}

Source:
  - user.js, line 1229
Since:
  - 0.3.0

Create a followee query for special user to query the user's followees.

##### Parameters:

Name | Type | Description
--- | --- | ---
`userObjectId` | String | The user object id.

##### Returns:

Type
  AV.FriendShipQuery

#### (static) followerQuery(userObjectId) → {AV.FriendShipQuery}

Source:
  - user.js, line 1210
Since:
  - 0.3.0

Create a follower query for special user to query the user's followers.

##### Parameters:

Name | Type | Description
--- | --- | ---
`userObjectId` | String | The user object id.

##### Returns:

Type
  AV.FriendShipQuery

#### (static) logIn(username, password) → {Promise}

Source:
  - user.js, line 912
See:
  - AV.User#logIn

Logs in a user with a username (or email) and password. On success, this saves the session to disk, so you can retrieve the currently logged in user using `current`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`username` | String | The username (or email) to log in with.
`password` | String | The password to log in with.

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) loginAnonymously() → {Promise.<AV.User>}

Source:
  - user.js, line 1164
Since:
  - 3.9.0

Creates an anonymous user.

##### Returns:

Type
  Promise.<AV.User>

#### (static) loginWithAuthData(authData, platform, optionsopt) → {Promise}

Source:
  - user.js, line 1054
Since:
  - 3.7.0
See:
  - https://leancloud.cn/docs/js_guide.html#绑定第三方平台账户

Sign up or logs in a user with a third party auth data(AccessToken). On success, this saves the session to disk, so you can retrieve the currently logged in user using `current`.

##### Example

    AV.User.loginWithAuthData({
      openid: 'abc123',
      access_token: '123abc',
      expires_in: 1382686496
    }, 'weixin').then(function(user) {
      //Access user here
    }).catch(function(error) {
      //console.error("error: ", error);
    });

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`authData` | Object |  | The response json data returned from third party token, maybe like { openid: 'abc123', access_token: '123abc', expires_in: 1382686496 }
`platform` | string |  | Available platform for sign up.

`options`

Object

<optional>

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`failOnNotExist` | boolean | <optional> | If true, the login request will fail when no user matches this authData exists.

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) loginWithAuthDataAndUnionId(authData, platform, unionId, unionLoginOptionsopt) → {Promise.<AV.User>}

Source:
  - user.js, line 1092
Since:
  - 3.7.0

Sign up or logs in a user with a third party authData and unionId.

##### Example

    AV.User.loginWithAuthDataAndUnionId({
      openid: 'abc123',
      access_token: '123abc',
      expires_in: 1382686496
    }, 'weixin', 'union123', {
      unionIdPlatform: 'weixin',
      asMainAccount: true,
    }).then(function(user) {
      //Access user here
    }).catch(function(error) {
      //console.error("error: ", error);
    });

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`authData` | Object |  | The response json data returned from third party token, maybe like { openid: 'abc123', access_token: '123abc', expires_in: 1382686496 }
`platform` | string |  | Available platform for sign up.
`unionId` | string |  |

`unionLoginOptions`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`unionIdPlatform` | string | <optional> | `'weixin'` | unionId platform
`asMainAccount` | boolean | <optional> | `false` | If true, the unionId will be associated with the user.
`failOnNotExist` | boolean | <optional> |  | If true, the login request will fail when no user matches this authData exists.

##### Returns:

A promise that is fulfilled with the user when completed.

Type
  Promise.<AV.User>

#### (static) loginWithEmail(email, password) → {Promise}

Source:
  - user.js, line 1022
Since:
  - 3.13.0

Logs in a user with email and password.

##### Parameters:

Name | Type | Description
--- | --- | ---
`email` | String | The user's email.
`password` | String | The password to log in with.

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) logInWithMobilePhone(mobilePhone, password) → {Promise}

Source:
  - user.js, line 1004
See:
  - AV.User#logIn

Logs in a user with a mobile phone number and password. On success, this saves the session to disk, so you can retrieve the currently logged in user using `current`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mobilePhone` | String | The user's mobilePhoneNumber
`password` | String | The password to log in with.

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) logInWithMobilePhoneSmsCode(mobilePhone, smsCode) → {Promise}

Source:
  - user.js, line 960
See:
  - AV.User#logIn

Logs in a user with a mobile phone number and sms code sent by AV.User.requestLoginSmsCode.On success, this saves the session to disk, so you can retrieve the currently logged in user using `current`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mobilePhone` | String | The user's mobilePhoneNumber
`smsCode` | String | The sms code sent by AV.User.requestLoginSmsCode

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) loginWithWeapp(optionsopt) → {Promise.<AV.User>}

Source:
  - user.js, line 1128
Since:
  - 2.0.0

使用当前使用小程序的微信用户身份注册或登录，成功后用户的 session 会在设备上持久化保存，之后可以使用 AV.User.current() 获取当前登录用户。 仅在小程序中可用。

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`options`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`preferUnionId` | boolean | <optional> |  | 当用户满足 获取 UnionId 的条件 时，是否使用 UnionId 登录。（since 3.13.0）
`unionIdPlatform` | string | <optional> | `'weixin'` | (only take effect when preferUnionId) unionId platform
`asMainAccount` | boolean | <optional> | `false` | (only take effect when preferUnionId) If true, the unionId will be associated with the user.
`failOnNotExist` | boolean | <optional> |  | If true, the login request will fail when no user matches this authData exists. (since v3.7.0)

##### Returns:

Type
  Promise.<AV.User>

#### (static) loginWithWeappWithUnionId(unionLoginOptionsopt)

Source:
  - user.js, line 1148
Since:
  - 3.13.0

使用当前使用小程序的微信用户身份注册或登录， 仅在小程序中可用。

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`unionLoginOptions`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`unionIdPlatform` | string | <optional> | `'weixin'` | unionId platform
`asMainAccount` | boolean | <optional> | `false` | If true, the unionId will be associated with the user.
`failOnNotExist` | boolean | <optional> |  | If true, the login request will fail when no user matches this authData exists. * @return {Promise.<AV.User>}

#### (static) logOut() → {Promise}

Source:
  - user.js, line 1185

Logs out the currently logged in user session. This will remove the session from disk, log out of linked services, and future calls to `current` will return `null`.

##### Returns:

Type
  Promise

#### (static) requestEmailVerify(email) → {Promise}

Source:
  - user.js, line 1272

Requests a verify email to be sent to the specified email address associated with the user account. This email allows the user to securely verify their email address on the AV site.

##### Parameters:

Name | Type | Description
--- | --- | ---
`email` | String | The email address associated with the user that doesn't verify their email address.

##### Returns:

Type
  Promise

#### (static) requestLoginSmsCode(mobilePhoneNumber, optionsopt) → {Promise}

Source:
  - user.js, line 1379

Requests a logIn sms code to be sent to the specified mobile phone number associated with the user account. This sms code allows the user to login by AV.User.logInWithMobilePhoneSmsCode function.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`mobilePhoneNumber` | String |  | The mobile phone number associated with the user that want to login by AV.User.logInWithMobilePhoneSmsCode

`options`

AuthOptions

<optional>

AuthOptions plus:

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`validateToken` | String | <optional> | a validate token returned by AV.Cloud.verifyCaptcha

##### Returns:

Type
  Promise

#### (static) requestMobilePhoneVerify(mobilePhoneNumber, optionsopt) → {Promise}

Source:
  - user.js, line 1289

Requests a verify sms code to be sent to the specified mobile phone number associated with the user account. This sms code allows the user to verify their mobile phone number by calling AV.User.verifyMobilePhone

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`mobilePhoneNumber` | String |  | The mobile phone number associated with the user that doesn't verify their mobile phone number.

`options`

AuthOptions

<optional>

AuthOptions plus:

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`validateToken` | String | <optional> | a validate token returned by AV.Cloud.verifyCaptcha

##### Returns:

Type
  Promise

#### (static) requestPasswordReset(email) → {Promise}

Source:
  - user.js, line 1251

Requests a password reset email to be sent to the specified email address associated with the user account. This email allows the user to securely reset their password on the AV site.

##### Parameters:

Name | Type | Description
--- | --- | ---
`email` | String | The email address associated with the user that forgot their password.

##### Returns:

Type
  Promise

#### (static) requestPasswordResetBySmsCode(mobilePhoneNumber, optionsopt) → {Promise}

Source:
  - user.js, line 1318

Requests a reset password sms code to be sent to the specified mobile phone number associated with the user account. This sms code allows the user to reset their account's password by calling AV.User.resetPasswordBySmsCode

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`mobilePhoneNumber` | String |  | The mobile phone number associated with the user that doesn't verify their mobile phone number.

`options`

AuthOptions

<optional>

AuthOptions plus:

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`validateToken` | String | <optional> | a validate token returned by AV.Cloud.verifyCaptcha

##### Returns:

Type
  Promise

#### (static) resetPasswordBySmsCode(code, password) → {Promise}

Source:
  - user.js, line 1344

Makes a call to reset user's account password by sms code and new password. The sms code is sent by AV.User.requestPasswordResetBySmsCode.

##### Parameters:

Name | Type | Description
--- | --- | ---
`code` | String | The sms code sent by AV.User.Cloud.requestSmsCode
`password` | String | The new password.

##### Returns:

A promise that will be resolved with the result of the function.

Type
  Promise

#### (static) signUp(username, password, attrsopt, optionsopt) → {Promise}

Source:
  - user.js, line 893
See:
  - AV.User#signUp

Signs up a new user with a username (or email) and password. This will create a new AV.User on the server, and also persist the session in localStorage so that you can access the user using #current.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`username` | String |  | The username (or email) to sign up with.
`password` | String |  | The password to sign up with.
`attrs` | Object | <optional> | Extra fields to set on the new user.
`options` | AuthOptions | <optional> |

##### Returns:

A promise that is fulfilled with the user when the signup completes.

Type
  Promise

#### (static) signUpOrlogInWithAuthData()

Source:
  - user.js, line 1061
Deprecated:
  - renamed to AV.User.loginWithAuthData

#### (static) signUpOrlogInWithAuthDataAndUnionId()

Source:
  - user.js, line 1109
Since:
  - 3.5.0
Deprecated:
  - renamed to AV.User.loginWithAuthDataAndUnionId

#### (static) signUpOrlogInWithMobilePhone(mobilePhoneNumber, smsCode, attributes, options) → {Promise}

Source:
  - user.js, line 980
See:
  - AV.User#signUpOrlogInWithMobilePhone
  - AV.Cloud.requestSmsCode

Sign up or logs in a user with a mobilePhoneNumber and smsCode. On success, this saves the session to disk, so you can retrieve the currently logged in user using `current`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mobilePhoneNumber` | String | The user's mobilePhoneNumber.
`smsCode` | String | The sms code sent by AV.Cloud.requestSmsCode
`attributes` | Object | The user's other attributes such as username etc.
`options` | AuthOptions |

##### Returns:

A promise that is fulfilled with the user when the login completes.

Type
  Promise

#### (static) verifyMobilePhone(code) → {Promise}

Source:
  - user.js, line 1363

Makes a call to verify sms code that sent by AV.User.Cloud.requestSmsCode If verify successfully,the user mobilePhoneVerified attribute will be true.

##### Parameters:

Name | Type | Description
--- | --- | ---
`code` | String | The sms code sent by AV.User.Cloud.requestSmsCode

##### Returns:

A promise that will be resolved with the result of the function.

Type
  Promise

#### associateWithAuthData(authData, platform) → {Promise.<AV.User>}

Source:
  - user.js, line 221
Since:
  - 3.3.0

Associate the user with a third party authData.

##### Example

    user.associateWithAuthData({
      openid: 'abc123',
      access_token: '123abc',
      expires_in: 1382686496
    }, 'weixin').then(function(user) {
      //Access user here
    }).catch(function(error) {
      //console.error("error: ", error);
    });

##### Parameters:

Name | Type | Description
--- | --- | ---
`authData` | Object | The response json data returned from third party token, maybe like { openid: 'abc123', access_token: '123abc', expires_in: 1382686496 }
`platform` | string | Available platform for sign up.

##### Returns:

A promise that is fulfilled with the user when completed.

Type
  Promise.<AV.User>

#### associateWithAuthDataAndUnionId(authData, platform, unionId, unionLoginOptionsopt) → {Promise.<AV.User>}

Source:
  - user.js, line 248
Since:
  - 3.5.0

Associate the user with a third party authData and unionId.

##### Example

    user.associateWithAuthDataAndUnionId({
      openid: 'abc123',
      access_token: '123abc',
      expires_in: 1382686496
    }, 'weixin', 'union123', {
      unionIdPlatform: 'weixin',
      asMainAccount: true,
    }).then(function(user) {
      //Access user here
    }).catch(function(error) {
      //console.error("error: ", error);
    });

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`authData` | Object |  | The response json data returned from third party token, maybe like { openid: 'abc123', access_token: '123abc', expires_in: 1382686496 }
`platform` | string |  | Available platform for sign up.
`unionId` | string |  |

`unionLoginOptions`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`unionIdPlatform` | string | <optional> | `'weixin'` | unionId platform
`asMainAccount` | boolean | <optional> | `false` | If true, the unionId will be associated with the user.

##### Returns:

A promise that is fulfilled with the user when completed.

Type
  Promise.<AV.User>

#### associateWithWeapp(optionsopt) → {Promise.<AV.User>}

Source:
  - user.js, line 271
Since:
  - 3.13.0

将用户与小程序用户进行关联。适用于为已经在用户系统中存在的用户关联当前使用小程序的微信帐号。 仅在小程序中可用。

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`options`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`preferUnionId` | boolean | <optional> |  | 当用户满足 获取 UnionId 的条件 时，是否将 UnionId 保存在用户账号中。
`unionIdPlatform` | string | <optional> | `'weixin'` | (only take effect when preferUnionId) unionId platform
`asMainAccount` | boolean | <optional> | `false` | (only take effect when preferUnionId) If true, the unionId will be associated with the user.

##### Returns:

Type
  Promise.<AV.User>

#### associateWithWeappWithUnionId(unionId, unionOptionsopt) → {Promise.<AV.User>}

Source:
  - user.js, line 299
Since:
  - 3.13.0

将用户与小程序用户进行关联。适用于为已经在用户系统中存在的用户关联当前使用小程序的微信帐号。 仅在小程序中可用。

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`unionId` | string |  |

`unionOptions`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`unionIdPlatform` | string | <optional> | `'weixin'` | unionId platform
`asMainAccount` | boolean | <optional> | `false` | If true, the unionId will be associated with the user.

##### Returns:

Type
  Promise.<AV.User>

#### authenticated()

Source:
  - user.js, line 788
Deprecated:
  - 如果要判断当前用户的登录状态是否有效，请使用 currentUser.isAuthenticated().then()， 如果要判断该用户是否是当前登录用户，请使用 user.id === currentUser.id

Checks whether this user is the current user and has been authenticated.

##### Returns:

(Boolean) whether this user is the current user and is logged in.

#### dissociateAuthData(platform) → {Promise.<AV.User>}

Source:
  - user.js, line 314
Since:
  - 3.3.0

Unlinks a user from a service.

##### Parameters:

Name | Type | Description
--- | --- | ---
`platform` | string |

##### Returns:

Type
  Promise.<AV.User>

#### fetch()

Source:
  - user.js, line 680
See:
  - AV.Object#fetch

#### follow(options, authOptionsopt)

Source:
  - user.js, line 605
Since:
  - 0.3.0

Follow a user

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`options`

Object | AV.User | String

if an AV.User or string is given, it will be used as the target user.

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`user` | AV.User | String |  | The target user or user's objectId to follow.
`attributes` | Object | <optional> | key-value attributes dictionary to be used as conditions of followerQuery/followeeQuery.

`authOptions` | AuthOptions | <optional> |

#### followeeQuery()

Source:
  - user.js, line 673
Since:
  - 0.3.0
See:
  - AV.User#followeeQuery

Create a followee query to query the user's followees.

#### followerQuery()

Source:
  - user.js, line 664
Since:
  - 0.3.0
See:
  - AV.User#followerQuery

Create a follower query to query the user's followers.

#### getEmail() → {String}

Source:
  - user.js, line 767
See:
  - AV.Object#get

Returns get("email").

##### Returns:

Type
  String

#### getMobilePhoneNumber() → {String}

Source:
  - user.js, line 728
See:
  - AV.Object#get

Returns get("mobilePhoneNumber").

##### Returns:

Type
  String

#### getRoles(optionsopt) → {Promise.<Array.<AV.Role>>}

Source:
  - user.js, line 856

Get this user's Roles.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`options` | AuthOptions | <optional> |

##### Returns:

A promise that is fulfilled with the roles when the query is complete.

Type
  Promise.<Array.<AV.Role>>

#### getSessionToken() → {String}

Source:
  - user.js, line 826

Get sessionToken of current user.

##### Returns:

sessionToken

Type
  String

#### getUsername() → {String}

Source:
  - user.js, line 719
See:
  - AV.Object#get

Returns get("username").

##### Returns:

Type
  String

#### isAnonymous() → {boolean}

Source:
  - user.js, line 352
Since:
  - 3.9.0

Checks whether a user is anonymous.

##### Returns:

Type
  boolean

#### isAuthenticated()

Source:
  - user.js, line 806
Since:
  - 2.0.0

检查该用户的登录状态是否有效，请注意该方法会校验 sessionToken 的有效性，是个异步方法。

##### Returns:

Promise.<Boolean>

#### isCurrent()

Source:
  - user.js, line 710
See:
  - AV.User#current

Returns true if `current` would return this user.

#### linkWithWeapp() → {Promise.<AV.User>}

Source:
  - user.js, line 281
Deprecated:
  - renamed to AV.User#associateWithWeapp

##### Returns:

Type
  Promise.<AV.User>

#### logIn() → {Promise}

Source:
  - user.js, line 560
See:
  - AV.User.logIn

Logs in a AV.User. On success, this saves the session to localStorage, so you can retrieve the currently logged in user using `current`.

A username and password must be set before calling logIn.

##### Returns:

A promise that is fulfilled with the user when the login is complete.

Type
  Promise

#### loginWithAuthData()

Source:
  - user.js, line 495
Since:
  - 3.7.0

The same with AV.User.loginWithAuthData, except that you can set attributes before login.

#### loginWithAuthDataAndUnionId()

Source:
  - user.js, line 503
Since:
  - 3.7.0

The same with AV.User.loginWithAuthDataAndUnionId, except that you can set attributes before login.

#### loginWithWeapp(optionsopt)

Source:
  - user.js, line 525
Since:
  - 3.7.0

The same with AV.User.loginWithWeapp, except that you can set attributes before login.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`options`

Object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`failOnNotExist` | boolean | <optional> |  | If true, the login request will fail when no user matches this authData exists.
`preferUnionId` | boolean | <optional> |  | 当用户满足 获取 UnionId 的条件 时，是否使用 UnionId 登录。（since 3.13.0）
`unionIdPlatform` | string | <optional> | `'weixin'` | (only take effect when preferUnionId) unionId platform
`asMainAccount` | boolean | <optional> | `false` | (only take effect when preferUnionId) If true, the unionId will be associated with the user.

#### loginWithWeappWithUnionId()

Source:
  - user.js, line 539
Since:
  - 3.13.0

The same with AV.User.loginWithWeappWithUnionId, except that you can set attributes before login.

#### refreshSessionToken(optionsopt) → {Promise.<AV.User>}

Source:
  - user.js, line 836
Since:
  - 2.1.0

Refresh sessionToken of current user.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`options` | AuthOptions | <optional> |

##### Returns:

user with refreshed sessionToken

Type
  Promise.<AV.User>

#### save()

Source:
  - user.js, line 575
See:
  - AV.Object#save

#### setEmail(email, options) → {Boolean}

Source:
  - user.js, line 778
See:
  - AV.Object#set

Calls set("email", email, options) and returns the result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`email` | String |
`options` | AuthOptions |

##### Returns:

Type
  Boolean

#### setMobilePhoneNumber(mobilePhoneNumber) → {Boolean}

Source:
  - user.js, line 738
See:
  - AV.Object#set

Calls set("mobilePhoneNumber", phoneNumber, options) and returns the result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mobilePhoneNumber` | String |

##### Returns:

Type
  Boolean

#### setPassword(password) → {Boolean}

Source:
  - user.js, line 758
See:
  - AV.Object#set

Calls set("password", password, options) and returns the result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`password` | String |

##### Returns:

Type
  Boolean

#### setUsername(username) → {Boolean}

Source:
  - user.js, line 748
See:
  - AV.Object#set

Calls set("username", username, options) and returns the result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`username` | String |

##### Returns:

Type
  Boolean

#### signUp(attrs, options) → {Promise}

Source:
  - user.js, line 407
See:
  - AV.User.signUp

Signs up a new user. You should call this instead of save for new AV.Users. This will create a new AV.User on the server, and also persist the session on disk so that you can access the user using `current`.

A username and password must be set before calling signUp.

##### Parameters:

Name | Type | Description
--- | --- | ---
`attrs` | Object | Extra fields to set on the new user, or null.
`options` | AuthOptions |

##### Returns:

A promise that is fulfilled when the signup finishes.

Type
  Promise

#### signUpOrlogInWithMobilePhone(attrs, options) → {Promise}

Source:
  - user.js, line 455
See:
  - AV.User.signUpOrlogInWithMobilePhone
  - AV.Cloud.requestSmsCode

Signs up a new user with mobile phone and sms code. You should call this instead of save for new AV.Users. This will create a new AV.User on the server, and also persist the session on disk so that you can access the user using `current`.

A username and password must be set before calling signUp.

##### Parameters:

Name | Type | Description
--- | --- | ---
`attrs` | Object | Extra fields to set on the new user, or null.
`options` | AuthOptions |

##### Returns:

A promise that is fulfilled when the signup finishes.

Type
  Promise

#### unfollow(options, authOptionsopt)

Source:
  - user.js, line 640
Since:
  - 0.3.0

Unfollow a user.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`options`

Object | AV.User | String

if an AV.User or string is given, it will be used as the target user.

###### Properties

Name | Type | Description
--- | --- | ---
`user` | AV.User | String | The target user or user's objectId to unfollow.

`authOptions` | AuthOptions | <optional> |

#### updatePassword(oldPassword, newPassword, options)

Source:
  - user.js, line 696

Update user's new password safely based on old password.

##### Parameters:

Name | Type | Description
--- | --- | ---
`oldPassword` | String | the old password.
`newPassword` | String | the new password.
`options` | AuthOptions |