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) -> LCRequestParameters
completionQueueThe queue where
completionbe executed, default is main.completionResult 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 : LCUserParameters
applicationThe application the user belong to, default is
LCApplication.default.usernameThe name of the user.
passwordThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.usernameThe name of the user.
passwordThe password of the user.
completionQueueThe queue where
completionbe executed, default is main.completionResult 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 : LCUserParameters
applicationThe application the user belong to, default is
LCApplication.default.emailThe email of the user.
passwordThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.emailThe email of the user.
passwordThe password of the user.
completionQueueThe queue where
completionbe executed, default is main.completionResult 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 : LCUserParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
passwordThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
passwordThe password of the user.
completionQueueThe queue where
completionbe executed, default is main.completionResult 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 : LCUserParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
verificationCodeThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
verificationCodeThe verification code sent to
mobilePhoneNumber.completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
-
Log in with session token synchronously.
Declaration
Swift
public static func logIn<User>(application: LCApplication = .default, sessionToken: String) -> LCValueResult<User> where User : LCUserParameters
applicationThe application the user belong to, default is
LCApplication.default.sessionTokenThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.sessionTokenThe session token of the user.
completionQueueThe queue where
completionbe executed, default is main.completionResult 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 : LCUserParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
verificationCodeThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
verificationCodeThe verification code sent to
mobilePhoneNumber.completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
-
Log out current user of the application.
Declaration
Swift
public static func logOut(application: LCApplication = .default)Parameters
applicationThe 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) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.emailThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.emailThe email address where the mail will be sent to.
completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
-
Request to send a verification code to specified mobile phone number synchronously.
Declaration
Swift
public static func requestVerificationCode( application: LCApplication = .default, mobilePhoneNumber: String) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number where the verification code will be sent to.
completionQueueThe queue where the completion be invoked, default is
DispatchQueue.main.completionThe 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) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number where the verification code will be sent to.
timeToLiveThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number where the verification code will be sent to.
timeToLiveThe time-to-live of the code.
completionQueueThe queue where the completion be invoked, default is
DispatchQueue.main.completionThe result callback.
Return Value
-
Verify mobile phone number with code synchronously.
Declaration
Swift
public static func verifyMobilePhoneNumber( application: LCApplication = .default, _ mobilePhoneNumber: String, verificationCode: String) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
verificationCodeThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of the user.
verificationCodeThe verification code sent to mobile phone number.
completionQueueThe queue where the completion be invoked, default is
DispatchQueue.main.completionThe 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) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.verificationCodeThe verification code sent to mobile phone number.
mobilePhoneNumberThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.verificationCodeThe verification code sent to mobile phone number.
mobilePhoneNumberThe mobile phone number to be bound or updated.
completionQueueThe queue where the completion be invoked, default is
DispatchQueue.main.completionThe 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) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number where the verification code will be sent to.
completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
-
Request password reset mail synchronously.
Declaration
Swift
public static func requestPasswordReset(application: LCApplication = .default, email: String) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.emailThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.emailThe email address where the password reset mail will be sent to.
completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
-
Request password reset verification code synchronously.
Declaration
Swift
public static func requestPasswordReset(application: LCApplication = .default, mobilePhoneNumber: String) -> LCBooleanResultParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe 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) -> LCRequestParameters
applicationThe application the user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number where the password reset verification code will be sent to.
completionQueueThe queue where
completionbe executed, default is main.completionResult 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) -> LCBooleanResultParameters
applicationThe application current user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of current user.
verificationCodeThe verification code in password reset message.
newPasswordThe 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) -> LCRequestParameters
applicationThe application current user belong to, default is
LCApplication.default.mobilePhoneNumberThe mobile phone number of current user.
verificationCodeThe verification code in password reset message.
newPasswordThe new password of current user.
completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
-
Update password for user synchronously.
Declaration
Swift
public func updatePassword(oldPassword: String, newPassword: String) -> LCBooleanResultParameters
oldPasswordThe old password of the user.
newPasswordThe 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) -> LCRequestParameters
oldPasswordThe old password of the user.
newPasswordThe new password of the user.
completionQueueThe queue where
completionbe executed, default is main.completionResult 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) -> LCBooleanResultParameters
authDataThe auth data of third party account.
platformThe platform of third party account. @see
AuthDataPlatform.unionIDThe union ID of the auth data.
unionIDPlatformThe 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) -> LCRequestParameters
authDataThe auth data of third party account.
platformThe platform of third party account. @see
AuthDataPlatform.unionIDThe union ID of the auth data.
unionIDPlatformThe platform of the
unionID. @seeAuthDataPlatform.options@see
AuthDataOptions.completionQueueThe queue where
completionbe executed, default is main.completionResult 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 -> LCBooleanResultParameters
authDataThe auth data of third party account.
platformThe platform of third party account. @see
AuthDataPlatform.unionIDThe union ID of the auth data.
unionIDPlatformThe 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 -> LCRequestParameters
authDataThe auth data of third party account.
platformThe platform of third party account. @see
AuthDataPlatform.unionIDThe union ID of the auth data.
unionIDPlatformThe platform of the
unionID. @seeAuthDataPlatform.options@see
AuthDataOptions.completionQueueThe queue where
completionbe executed, default is main.completionResult 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 -> LCRequestParameters
platformThe platform of third party account. @see
AuthDataPlatform.completionQueueThe queue where
completionbe executed, default is main.completionResult callback.
View on GitHub
Install in Dash
LCUser Class Reference