LCUser
open class LCUser : LCObject
LeanCloud user type.
A base type of LeanCloud built-in user system. You can extend this class with custom properties. However, LCUser can be extended only once.
-
Username of user.
Declaration
Swift
@objc dynamic public var username: LCString?
-
Password of user.
Note
this property will not be filled in when fetched or logged in for security.Declaration
Swift
@objc dynamic public var password: LCString?
-
Email of user.
If the “Enable Email Verification” application option is enabled, a verification email will be sent to user when user registered with an email address.
Declaration
Swift
@objc dynamic public var email: LCString?
-
A flag indicates whether email is verified or not.
Declaration
Swift
@objc dynamic public private(set) var emailVerified: LCBool? { get }
-
Mobile phone number.
If the “Enable Mobile Phone Number Verification” application option is enabled, an sms message will be sent to user’s phone when user registered with a phone number.
Declaration
Swift
@objc dynamic public var mobilePhoneNumber: LCString?
-
A flag indicates whether mobile phone is verified or not.
Declaration
Swift
@objc dynamic public private(set) var mobilePhoneVerified: LCBool? { get }
-
Auth Data of third party account.
Declaration
Swift
@objc dynamic public private(set) var authData: LCDictionary? { get }
-
Session token of user authenticated by server.
Declaration
Swift
@objc dynamic public private(set) var sessionToken: LCString? { get }
-
Declaration
Swift
public final override class func objectClassName() -> String
-
Sign up an user synchronously.
Declaration
Swift
public func signUp() -> LCBooleanResult
-
Sign up an user asynchronously.
Declaration
Swift
@discardableResult public func signUp( completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Log in with username and password synchronously.
Declaration
Swift
public static func logIn<User>(application: LCApplication = .default, username: String, password: String) -> LCValueResult<User> where User : LCUser
Parameters
application
The application the user belong to, default is
LCApplication.default
.username
The name of the user.
password
The password of the user.
-
Log in with username and password asynchronously.
Declaration
Swift
@discardableResult public static func logIn<User: LCUser>( application: LCApplication = .default, username: String, password: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCValueResult<User>) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.username
The name of the user.
password
The password of the user.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Log in with email and password synchronously.
Declaration
Swift
public static func logIn<User>(application: LCApplication = .default, email: String, password: String) -> LCValueResult<User> where User : LCUser
Parameters
application
The application the user belong to, default is
LCApplication.default
.email
The email of the user.
password
The password of the user.
-
Log in with email and password asynchronously.
Declaration
Swift
@discardableResult public static func logIn<User: LCUser>( application: LCApplication = .default, email: String, password: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCValueResult<User>) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.email
The email of the user.
password
The password of the user.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Log in with mobile phone number and password synchronously.
Declaration
Swift
public static func logIn<User>(application: LCApplication = .default, mobilePhoneNumber: String, password: String) -> LCValueResult<User> where User : LCUser
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
password
The password of the user.
-
Log in with mobile phone number and password asynchronously.
Declaration
Swift
@discardableResult public static func logIn<User: LCUser>( application: LCApplication = .default, mobilePhoneNumber: String, password: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCValueResult<User>) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
password
The password of the user.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Log in with mobile phone number and verification code synchronously.
Declaration
Swift
public static func logIn<User>(application: LCApplication = .default, mobilePhoneNumber: String, verificationCode: String) -> LCValueResult<User> where User : LCUser
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
verificationCode
The verification code sent to
mobilePhoneNumber
. -
Log in with mobile phone number and verification code asynchronously.
Declaration
Swift
@discardableResult public static func logIn<User: LCUser>( application: LCApplication = .default, mobilePhoneNumber: String, verificationCode: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCValueResult<User>) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
verificationCode
The verification code sent to
mobilePhoneNumber
.completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Log in with session token synchronously.
Declaration
Swift
public static func logIn<User>(application: LCApplication = .default, sessionToken: String) -> LCValueResult<User> where User : LCUser
Parameters
application
The application the user belong to, default is
LCApplication.default
.sessionToken
The session token of the user.
-
Log in with session token asynchronously.
Declaration
Swift
@discardableResult public static func logIn<User: LCUser>( application: LCApplication = .default, sessionToken: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCValueResult<User>) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.sessionToken
The session token of the user.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Sign up or log in with mobile phone number and verification code synchronously.
Declaration
Swift
public static func signUpOrLogIn<User>(application: LCApplication = .default, mobilePhoneNumber: String, verificationCode: String) -> LCValueResult<User> where User : LCUser
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
verificationCode
The verification code sent to
mobilePhoneNumber
. -
Sign up or log in with mobile phone number and verification code asynchronously.
Declaration
Swift
@discardableResult public static func signUpOrLogIn<User: LCUser>( application: LCApplication = .default, mobilePhoneNumber: String, verificationCode: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCValueResult<User>) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
verificationCode
The verification code sent to
mobilePhoneNumber
.completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Log out current user of the application.
Declaration
Swift
public static func logOut(application: LCApplication = .default)
Parameters
application
The application current user belong to, default is
LCApplication.default
.
-
Request to send a verification mail to specified email address synchronously.
Declaration
Swift
public static func requestVerificationMail(application: LCApplication = .default, email: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.email
The email address where the mail will be sent to.
-
Request to send a verification mail to specified email address asynchronously.
Declaration
Swift
@discardableResult public static func requestVerificationMail( application: LCApplication = .default, email: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.email
The email address where the mail will be sent to.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Request to send a verification code to specified mobile phone number synchronously.
Declaration
Swift
public static func requestVerificationCode( application: LCApplication = .default, mobilePhoneNumber: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the verification code will be sent to.
Return Value
-
Request to send a verification code to specified mobile phone number asynchronously.
Declaration
Swift
@discardableResult public static func requestVerificationCode( application: LCApplication = .default, mobilePhoneNumber: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the verification code will be sent to.
completionQueue
The queue where the completion be invoked, default is
DispatchQueue.main
.completion
The result callback.
Return Value
-
Request to send a verification code to bind or update mobile phone number synchronously.
Declaration
Swift
public static func requestVerificationCode( application: LCApplication = .default, forUpdatingMobilePhoneNumber mobilePhoneNumber: String, timeToLive: Int? = nil) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the verification code will be sent to.
timeToLive
The time-to-live of the code.
Return Value
-
requestVerificationCode(application:
forUpdatingMobilePhoneNumber: timeToLive: completionQueue: completion: ) Request to send a verification code to bind or update mobile phone number asynchronously.
Declaration
Swift
@discardableResult public static func requestVerificationCode( application: LCApplication = .default, forUpdatingMobilePhoneNumber mobilePhoneNumber: String, timeToLive: Int? = nil, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the verification code will be sent to.
timeToLive
The time-to-live of the code.
completionQueue
The queue where the completion be invoked, default is
DispatchQueue.main
.completion
The result callback.
Return Value
-
Verify mobile phone number with code synchronously.
Declaration
Swift
public static func verifyMobilePhoneNumber( application: LCApplication = .default, _ mobilePhoneNumber: String, verificationCode: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
verificationCode
The verification code sent to mobile phone number.
Return Value
-
Verify mobile phone number with code asynchronously.
Declaration
Swift
@discardableResult public static func verifyMobilePhoneNumber( application: LCApplication = .default, _ mobilePhoneNumber: String, verificationCode: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of the user.
verificationCode
The verification code sent to mobile phone number.
completionQueue
The queue where the completion be invoked, default is
DispatchQueue.main
.completion
The result callback.
Return Value
-
Verify code to bind or update mobile phone number synchronously.
Declaration
Swift
public static func verifyVerificationCode( application: LCApplication = .default, _ verificationCode: String, toUpdateMobilePhoneNumber mobilePhoneNumber: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.verificationCode
The verification code sent to mobile phone number.
mobilePhoneNumber
The mobile phone number to be bound or updated.
Return Value
-
Verify code to bind or update mobile phone number asynchronously.
Declaration
Swift
@discardableResult public static func verifyVerificationCode( application: LCApplication = .default, _ verificationCode: String, toUpdateMobilePhoneNumber mobilePhoneNumber: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.verificationCode
The verification code sent to mobile phone number.
mobilePhoneNumber
The mobile phone number to be bound or updated.
completionQueue
The queue where the completion be invoked, default is
DispatchQueue.main
.completion
The result callback.
Return Value
-
Request a verification code for login with mobile phone number synchronously.
Declaration
Swift
public static func requestLoginVerificationCode(application: LCApplication = .default, mobilePhoneNumber: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the verification code will be sent to.
-
Request a verification code for login with mobile phone number asynchronously.
Declaration
Swift
@discardableResult public static func requestLoginVerificationCode( application: LCApplication = .default, mobilePhoneNumber: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the verification code will be sent to.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Request password reset mail synchronously.
Declaration
Swift
public static func requestPasswordReset(application: LCApplication = .default, email: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.email
The email address where the password reset mail will be sent to.
-
Request password reset email asynchronously.
Declaration
Swift
@discardableResult public static func requestPasswordReset( application: LCApplication = .default, email: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.email
The email address where the password reset mail will be sent to.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Request password reset verification code synchronously.
Declaration
Swift
public static func requestPasswordReset(application: LCApplication = .default, mobilePhoneNumber: String) -> LCBooleanResult
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the password reset verification code will be sent to.
-
Request password reset verification code asynchronously.
Declaration
Swift
@discardableResult public static func requestPasswordReset( application: LCApplication = .default, mobilePhoneNumber: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application the user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number where the password reset verification code will be sent to.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Reset password with verification code and new password synchronously. This method will reset password of current user. If current user is nil, in other words, no user logged in, Password reset will be failed because of permission.
Declaration
Swift
public static func resetPassword(application: LCApplication = .default, mobilePhoneNumber: String, verificationCode: String, newPassword: String) -> LCBooleanResult
Parameters
application
The application current user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of current user.
verificationCode
The verification code in password reset message.
newPassword
The new password of current user.
-
resetPassword(application:
mobilePhoneNumber: verificationCode: newPassword: completionQueue: completion: ) Reset password with verification code and new password asynchronously. This method will reset password of current user. If current user is nil, in other words, no user logged in, Password reset will be failed because of permission.
Declaration
Swift
@discardableResult public static func resetPassword( application: LCApplication = .default, mobilePhoneNumber: String, verificationCode: String, newPassword: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
application
The application current user belong to, default is
LCApplication.default
.mobilePhoneNumber
The mobile phone number of current user.
verificationCode
The verification code in password reset message.
newPassword
The new password of current user.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Update password for user synchronously.
Declaration
Swift
public func updatePassword(oldPassword: String, newPassword: String) -> LCBooleanResult
Parameters
oldPassword
The old password of the user.
newPassword
The new password of the user.
-
Update password for user asynchronously.
Declaration
Swift
@discardableResult public func updatePassword( oldPassword: String, newPassword: String, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
oldPassword
The old password of the user.
newPassword
The new password of the user.
completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
The third party platform
See moreDeclaration
Swift
public enum AuthDataPlatform
-
The options of auth data
See moreDeclaration
Swift
public struct AuthDataOptions : OptionSet
-
Login with third party auth data synchronously.
Declaration
Swift
public func logIn( authData: [String: Any], platform: AuthDataPlatform, unionID: String? = nil, unionIDPlatform: AuthDataPlatform? = nil, options: AuthDataOptions? = nil) -> LCBooleanResult
Parameters
authData
The auth data of third party account.
platform
The platform of third party account. @see
AuthDataPlatform
.unionID
The union ID of the auth data.
unionIDPlatform
The platform of the
unionID
. @seeAuthDataPlatform
.options
@see
AuthDataOptions
. -
Login with third party auth data asynchronously.
Declaration
Swift
@discardableResult public func logIn( authData: [String: Any], platform: AuthDataPlatform, unionID: String? = nil, unionIDPlatform: AuthDataPlatform? = nil, options: AuthDataOptions? = nil, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequest
Parameters
authData
The auth data of third party account.
platform
The platform of third party account. @see
AuthDataPlatform
.unionID
The union ID of the auth data.
unionIDPlatform
The platform of the
unionID
. @seeAuthDataPlatform
.options
@see
AuthDataOptions
.completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Associate the user with third party auth data synchronously.
Declaration
Swift
public func associate( authData: [String: Any], platform: AuthDataPlatform, unionID: String? = nil, unionIDPlatform: AuthDataPlatform? = nil, options: AuthDataOptions? = nil) throws -> LCBooleanResult
Parameters
authData
The auth data of third party account.
platform
The platform of third party account. @see
AuthDataPlatform
.unionID
The union ID of the auth data.
unionIDPlatform
The platform of the
unionID
. @seeAuthDataPlatform
.options
@see
AuthDataOptions
. -
Associate the user with third party auth data asynchronously.
Declaration
Swift
@discardableResult public func associate( authData: [String: Any], platform: AuthDataPlatform, unionID: String? = nil, unionIDPlatform: AuthDataPlatform? = nil, options: AuthDataOptions? = nil, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) throws -> LCRequest
Parameters
authData
The auth data of third party account.
platform
The platform of third party account. @see
AuthDataPlatform
.unionID
The union ID of the auth data.
unionIDPlatform
The platform of the
unionID
. @seeAuthDataPlatform
.options
@see
AuthDataOptions
.completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.
-
Disassociate the user with third party auth data synchronously.
- platform: The platform of third party account. @see
AuthDataPlatform
.
Declaration
Swift
public func disassociate(authData platform: AuthDataPlatform) throws -> LCBooleanResult
- platform: The platform of third party account. @see
-
Disassociate the user with third party auth data asynchronously.
Declaration
Swift
@discardableResult public func disassociate( authData platform: AuthDataPlatform, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) throws -> LCRequest
Parameters
platform
The platform of third party account. @see
AuthDataPlatform
.completionQueue
The queue where
completion
be executed, default is main.completion
Result callback.