CloudMine iOS SDK  1.5.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
CMUser Class Reference

#import <CMUser.h>

Inherits NSObject, and <CMSerializable>.

Instance Methods

(NSString *userId) - __attribute__
 
(id) - initWithUserId:andPassword:
 
(id) - initWithEmail:andPassword:
 
(id) - initWithUsername:andPassword:
 
(id) - initWithUserId:andUsername:andPassword:
 
(id) - initWithEmail:andUsername:andPassword:
 
(void) - loginWithCallback:
 

Properties

NSString * email
 
NSString * password
 
NSString * username
 
NSString * token
 
NSDate * tokenExpiration
 
BOOL isCreatedRemotely
 
BOOL isDirty
 
BOOL isLoggedIn
 
NSArray * services
 
- Properties inherited from <CMSerializable>
NSString * objectId
 
(void) - loginWithSocialNetwork:viewController:params:callback:
 
(void) - logoutWithCallback:
 
(void) - createAccountWithCallback:
 
(void) - createAccountAndLoginWithCallback:
 
(void) - changePasswordTo:from:callback:
 
(void) - changeUserIdTo:password:callback:
 
(void) - changeEmailTo:password:callback:
 
(void) - changeUsernameTo:password:callback:
 
(void) - changeUserCredentialsWithPassword:newPassword:newUsername:newUserId:callback:
 
(void) - changeUserCredentialsWithPassword:newPassword:newUsername:newEmail:callback:
 
(void) - resetForgottenPasswordWithCallback:
 
(void) - save:
 
(void) + allUsersWithCallback:
 
(void) + searchUsers:callback:
 
(void) + userWithIdentifier:callback:
 

Additional Inherited Members

- Class Methods inherited from <CMSerializable>
(NSString *) + className
 

Detailed Description

Representation of an end-user in CloudMine. This class manages session state (i.e. tokens and all that).

Subclassing Notes You can subclass CMUser to add your own user profile fields, if you'd like. CMUser conforms to CMSerializable, so you should implement encodeWithCoder: and initWithCoder: in the same way as you would for a CMObject subclass. Be sure to call super's implementation from both of those methods! Your custom fields will be pushed to the server when you first call createAccountWithCallback: (CMUser) or createAccountAndLoginWithCallback: (CMUser). Upon subsequent logins, the custom fields will be updated with those stored on CloudMine.

Definition at line 87 of file CMUser.h.

Method Documentation

- (NSString* userId) __attribute__ ((deprecated)) 

The user's identifier (i.e. email address).

DEPRECATED: Now use email. This will be removed at a future date.

Note: This variable now maps directly to email, and will be removed at a futre date. Please use email instead.

+ (void) allUsersWithCallback: (CMUserFetchCallback callback

Asynchronously fetch all the users of this app. This will download the profiles of all the users of your app, and is useful for displaying lists of people to share with or running analytics on your users yourself. On completion, the callback block will be called with an array of CMUser objects (or your custom subclass, if applicable) as well as a dictionary of errors.

Parameters
callbackThe block that will be called on completion of the operation.
- (void) changeEmailTo: (NSString *)  newEmail
password: (NSString *)  currentPassword
callback: (CMUserOperationCallback callback 

Asynchronously change the Email for this user. For security purposes, you must have the user enter his or her current password in order to perform this operation. The user does not need to be logged in to change this property. If this method is successful then the user is automatically logged in again to get their new session token. If it is not successful, the user is not logged out. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Possible result codes:

  • CMUserAccountEmailChangeSucceeded
  • CMUserAccountCredentialChangeFailedInvalidCredentials
  • CMUserAccountCredentialChangeFailedDuplicateEmail
  • CMUserAccountOperationFailedUnknownAccount
  • CMUserAccountUnknownResult
Parameters
newEmailThe new email for this user.
currentPasswordThe current password for the user.
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
- (void) changePasswordTo: (NSString *)  newPassword
from: (NSString *)  oldPassword
callback: (CMUserOperationCallback callback 

Asynchronously change the password for this user. For security purposes, you must have the user enter his or her old password and new password in order to perform this operation. This operation will succeed regardless of whether the user's CMUser instance is logged in or not. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

See Also
- resetForgottenPasswordWithCallback: instead if if the user has forgotten his or her password

Possible result codes:

  • CMUserAccountPasswordChangeSucceeded
  • CMUserAccountPasswordChangeFailedInvalidCredentials
  • CMUserAccountOperationFailedUnknownAccount
Parameters
newPasswordThe new password to use.
oldPasswordThe user's old password.
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
https://cloudmine.me/docs/ios/reference#users_pass_change
- (void) changeUserCredentialsWithPassword: (NSString *)  currentPassword
newPassword: (NSString *)  newPassword
newUsername: (NSString *)  newUsername
newEmail: (NSString *)  newEmail
callback: (CMUserOperationCallback callback 

Asynchronously change the credentials for this user. This method can be called with any combination of new values for the user. It is useful when you want to change more than one value for the user, such as his username, email, and password. For any operation, the current password must be provided. The user does not need to be logged in to use this method. If this method is successful then the user is automatically logged in again to get their new session token. If it is not successful, the user is not logged out. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Possible result codes:

  • CMUserAccountPasswordChangeSucceeded
  • CMUserAccountEmailChangeSucceeded
  • CMUserAccountUsernameChangeSucceeded
  • CMUserAccountCredentialsChangeSucceeded Used if more than one credential field was changed.
  • CMUserAccountCredentialChangeFailedDuplicateEmail
  • CMUserAccountCredentialChangeFailedDuplicateUsername
  • CMUserAccountCredentialChangeFailedDuplicateInfo
  • CMUserAccountCredentialChangeFailedInvalidCredentials
  • CMUserAccountOperationFailedUnknownAccount
  • CMUserAccountUnknownResult
Parameters
currentPasswordThe new password for this user.
newPasswordCan be nil. The new password for the user.
newUsernameCan be nil. The new username for this user.
newEmailCan be nil. The new email for this user.
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
- (void) changeUserCredentialsWithPassword: (NSString *)  currentPassword
newPassword: (NSString *)  newPassword
newUsername: (NSString *)  newUsername
newUserId: (NSString *)  newUserId 

DEPRECATED: Use changeUserCredentialsWithPassword:newPassword:newUsername:newEmail:callback: instead.

Asynchronously change the credentials for this user. This method can be called with any combination of new values for the user. It is useful when you want to change more than one value for the user, such as his username, userId, and password. For any operation, the current password must be provided. The user does not need to be logged in to use this method. If this method is successful then the user is automatically logged in again to get their new session token. If it is not successful, the user is not logged out. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Possible result codes:

  • CMUserAccountPasswordChangeSucceeded
  • CMUserAccountUserIdChangeSucceeded
  • CMUserAccountUsernameChangeSucceeded
  • CMUserAccountCredentialsChangeSucceeded Used if more than one credential field was changed.
  • CMUserAccountCredentialChangeFailedDuplicateUserId
  • CMUserAccountCredentialChangeFailedDuplicateUsername
  • CMUserAccountCredentialChangeFailedDuplicateInfo
  • CMUserAccountCredentialChangeFailedInvalidCredentials
  • CMUserAccountOperationFailedUnknownAccount
  • CMUserAccountUnknownResult
Parameters
currentPasswordThe new password for this user.
newPasswordCan be nil. The new password for the user.
newUsernameCan be nil. The new username for this user.
newUserIdCan be nil. The new userId for this user.
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
- (void) changeUserIdTo: (NSString *)  newUserId
password: (NSString *)  currentPassword 

DEPRECATED: This method is now deprecated. Use changeEmailTo:password:callback: instead.

Asynchronously change the User ID for this user. For security purposes, you must have the user enter his or her current password in order to perform this operation. The user does not need to be logged in to change this property. If this method is successful then the user is automatically logged in again to get their new session token. If it is not successful, the user is not logged out. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

See Also
userId for notes on how User ID is now used.

Possible result codes:

  • CMUserAccountUserIdChangeSucceeded
  • CMUserAccountCredentialChangeFailedInvalidCredentials
  • CMUserAccountCredentialChangeFailedDuplicateUserId
  • CMUserAccountOperationFailedUnknownAccount
  • CMUserAccountUnknownResult
Parameters
newUserIdThe new User ID for this user. It needs to be in the form of an email address. If you don't want to use an email then you should username
currentPasswordThe current password for the user.
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
- (void) changeUsernameTo: (NSString *)  newUsername
password: (NSString *)  currentPassword
callback: (CMUserOperationCallback callback 

Asynchronously change the Username for this user. For security purposes, you must have the user enter his or her current password in order to perform this operation. The user does not need to be logged in to change this property. If this method is successful then the user is automatically logged in again to get their new session token. If it is not successful, the user is not logged out. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Possible result codes:

  • CMUserAccountUsernameChangeSucceeded
  • CMUserAccountCredentialChangeFailedInvalidCredentials
  • CMUserAccountCredentialChangeFailedDuplicateUsername
  • CMUserAccountOperationFailedUnknownAccount
  • CMUserAccountUnknownResult
Parameters
newUsernameThe new Username for this user.
currentPasswordThe current password for the user.
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
- (void) createAccountAndLoginWithCallback: (CMUserOperationCallback callback

A convenient method to create an account for the user if it doesn't already exist, and then log the user in if the account was successfully created or already existed. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Possible result codes:

  • CMUserAccountLoginSucceeded
  • CMUserAccountLoginFailedIncorrectCredentials (if the account already exists and the supplied credentials are incorrect)
Parameters
callbackThe block that will be called on completion of the operation.
- (void) createAccountWithCallback: (CMUserOperationCallback callback

Asynchronously create a new account for the user on CloudMine. This must be done once for each user before they can login. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Note that this method simply creates the user account; it does not log the user in. createAccountAndLoginWithCallback: is a convenience method that creates and logs the user in at the same time.

Possible result codes:

  • CMUserAccountCreateSucceeded
  • CMUserAccountCreateFailedInvalidRequest
  • CMUserAccountCreateFailedDuplicateAccount
Parameters
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
https://cloudmine.me/docs/ios/reference#users_create
- (id) initWithEmail: (NSString *)  theEmail
andPassword: (NSString *)  thePassword 

Initialize the user with an email address and password.

- (id) initWithEmail: (NSString *)  theEmail
andUsername: (NSString *)  theUsername
andPassword: (NSString *)  thePassword 

Initialize the user with an email, username, and password.

- (id) initWithUserId: (NSString *)  userId

Initialize the user with an email address and password.

DEPRECATED: Now use initWithEmail:andPassword: instead.

- (id) initWithUserId: (NSString *)  theUserId
andUsername: (NSString *)  theUsername 

Initialize the user with an email, username, and password.

DEPRECATED: Now use initWithEmail:andUsername:andPassword: instead.

- (id) initWithUsername: (NSString *)  theUsername
andPassword: (NSString *)  thePassword 

Initialize the user with a Username and password.

- (void) loginWithCallback: (CMUserOperationCallback callback

Asynchronously login the user and create a new session. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Upon successful login, the CMUser::token property will be set to the user's new session token and the CMUser::password field will be cleared for security reasons. The CMUser::tokenExpiration property will also be set with the expiration date and time of the session token. In addition, all your custom properties (if you are using a custom subclass of CMUser) will be populated for you using key-value coding. All these properties will be set before the callback block is invoked.

Important This method will cause the user's profile fields (i.e. any custom fields you have defined on your CMUser subclass) to be synced with the server state.

Possible result codes:

  • CMUserAccountLoginSucceeded
  • CMUserAccountLoginFailedIncorrectCredentials
  • CMUserAccountOperationFailedUnknownAccount
Parameters
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
isLoggedIn
https://cloudmine.me/docs/ios/reference#users_login
- (void) loginWithSocialNetwork: (NSString *)  service
viewController: (UIViewController *)  viewController
params: (NSDictionary *)  params
callback: (CMUserOperationCallback callback 

Login with social networking sites through Singly. Calls a UIWebView for authentication, which loads the authentication page of the social network you specify.

If you call this method and the user is logged in already, it will link the logged in user with the social network account. If the user is not logged in, this call will create a new user.

Upon successful login, the CMUser::token property will be set to the user's new session token The CMUser::tokenExpiration property will also be set with the expiration date and time of the session token. In addition, all your custom properties (if you are using a custom subclass of CMUser) will be populated for you using key-value coding. All these properties will be set before the callback block is invoked.

Possible result codes:

  • CMUserAccountLoginSucceeded
  • CMUserAccountLoginFailedIncorrectCredentials
  • CMUserAccountOperationFailedUnknownAccount
Parameters
serviceThe social service to be logged into
viewControllerthe current view controller in use when this method is called
paramsAny extra parameters you want passed in to the authentication request. This dictionary is parsed where each key value pair becomes "&key=value". We do not encode the URL after this, so any encoding will need to be done by the creator. This is a good place to put scope, for example:"scope" : @"gist,repo"}
callbackThe block that will be called on completion of the operation.
See Also
https://cloudmine.me/docs/api#users_social
- (void) logoutWithCallback: (CMUserOperationCallback callback

Asynchronously logout the user and clear their session and session token. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

Upon successful logout, the CMUser::token and CMUser::tokenExpiration properties will be set to nil. This will occur before the callback block is invoked.

Possible result codes:

  • CMUserAccountLogoutSucceeded
  • CMUserAccountOperationFailedUnknownAccount
Parameters
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
isLoggedIn
https://cloudmine.me/docs/ios/reference#users_logout
- (void) resetForgottenPasswordWithCallback: (CMUserOperationCallback callback

Asynchronously reset the password for this user. This method is used to reset a user's password if he or she forgot it. This method of course does not require the user to be logged in in order to function. On completion, the callback block will be called with the result of the operation and any messages returned by the server contained in an array. See the CloudMine documentation online for the possible contents of this array.

This method causes an email to be sent to the user with a link that allows them to reset their password from their browser. Upon creating a new password, the user will be able to login with it via your app immediately.

Possible result codes:

  • CMUserAccountPasswordResetEmailSent
  • CMUserAccountOperationFailedUnknownAccount
Parameters
callbackThe block that will be called on completion of the operation.
See Also
CMUserAccountResult
https://cloudmine.me/docs/ios/reference#users_pass_reset
- (void) save: (CMUserOperationCallback callback

Saves this user's profile. If you call this before the user's account has been created server-side, this method is the same as CMUser::createAccountWithCallback. If the account already exists, the profile will be updated server-side to reflect the state of this object.

Important implementation note If this user is not logged in, they must first be logged in before a save can be completed. The library will automatically do that for you if the user is logged out. However, this has the effect of ignoring any server-side changes that may have occured since you last synchronized the state of the user's profile data. If you need to synchronize state with the server before modifying the user's profile, you need to first login using loginWithCallback: (which will sync the state of the profile) and then modify the user profile as you wish. After that, calling this method will simply save.

Parameters
callbackThe block that will be called on completion of the operation.
+ (void) searchUsers: (NSString *)  query
callback: (CMUserFetchCallback callback 

Asynchronously search all profiles of users of this app for matching fields. This will download the profiles of all matching users of your app, and is useful for displaying and filtering lists of people to share with or running analytics on your users yourself. On completion, the callback block will be called with an array of CMUser objects (or your custom subclass, if applicable) as well as a dictionary of errors.

Parameters
queryThe search query to run against all user profiles. This is the same syntax as defined at https://cloudmine.me/docs/api#query_syntax and used by CMStore's search methods.
callbackThe block that will be called on completion of the operation.
+ (void) userWithIdentifier: (NSString *)  identifier
callback: (CMUserFetchCallback callback 

Asynchronously fetch a single user profile object from CloudMine given its object id. You can access this via CMUser::objectId.

Parameters
identifierThe objectId of the user profile to fetch.
callbackThe block that will be called on completion of the operation.

Property Documentation

- (NSString*) email
readwriteatomicstrong

The user's email (the new User ID).

Definition at line 101 of file CMUser.h.

- (BOOL) isCreatedRemotely
readatomicassign

YES when the user's account and profile have been created server-side. If NO, it means the user exists only locally in your app.

Definition at line 127 of file CMUser.h.

- (BOOL) isDirty
readatomicassign

The object is dirty if any changes have been made locally that have not yet been persisted to the server.

Definition at line 132 of file CMUser.h.

- (BOOL) isLoggedIn
readatomicassign

YES if the user is logged in and NO otherwise. Being logged in is defined by having a session token set and having a token expiration date in the future.

See Also
CMUser::token
CMUser::tokenExpiration

Definition at line 141 of file CMUser.h.

- (NSString*) password
readwriteatomicstrong

The user's plaintext password.

Definition at line 106 of file CMUser.h.

- (NSArray*) services
readwriteatomicstrong

The social services the user has linked their profile to.

Definition at line 146 of file CMUser.h.

- (NSString*) token
readwriteatomicstrong

The user's session token, as assigned after a successful login operation. When setting this property, CMUser::password will be set to nil for security reasons.

Definition at line 117 of file CMUser.h.

- (NSDate*) tokenExpiration
readwriteatomicstrong

The date and time at which the session token is no longer valid.

Definition at line 122 of file CMUser.h.

- (NSString*) username
readwriteatomicstrong

The user's plaintext password

Definition at line 111 of file CMUser.h.


The documentation for this class was generated from the following file: