+
+
+

UsergridUser

+
+
+
public class UsergridUser : UsergridEntity
+ +
+
+

UsergridUser is a special subclass of UsergridEntity that supports functions and properties unique to users.

+ +
+
+
+
    +
  • +
    + + + + subscript(_:) + +
    +
    +
    +
    +
    +
    +

    Subscript for the UsergridUser class.

    + +
    +

    Warning

    +

    When setting a properties value must be a valid JSON object.

    + +
    + +

  • Example usage: +“` +let someName = usergridUser[name]

  • + +

    usergridUser[name] = someName +”`

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    override public subscript(propertyName: String) -> AnyObject?
    + +
    +
    +
    +
    +
  • +
+
+
+ +
    +
  • +
    + + + + auth + +
    +
    +
    +
    +
    +
    +

    The UsergridUserAuth object if this user was authenticated.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var auth: UsergridUserAuth?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + name + +
    +
    +
    +
    +
    +
    +

    Property helper method for the UsergridUser objects UsergridUserProperties.Name.

    + +

    Unlike UsergridEntity objects, UsergridUser’s can change their name property which is why we provide a getter here.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    override public var name: String?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + username + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Username.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var username: String?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + password + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Password.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var password: String?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + email + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Email.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var email: String?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + age + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Age.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var age: NSNumber?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + usernameOrEmail + +
    +
    +
    +
    +
    +
    +

    Property helper method to get the username or email of the UsergridUser.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var usernameOrEmail: String? { return self.username ?? self.email }
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + activated + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Activated.

    + +

    Indicates whether the user account has been activated or not.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var activated: Bool
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + disabled + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Disabled.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var disabled: Bool
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + picture + +
    +
    +
    +
    +
    +
    +

    Property getter and setter helpers for the UsergridUser objects UsergridUserProperties.Picture.

    + +

    URL path to user’s profile picture. Defaults to Gravatar for email address.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var picture: String?
    + +
    +
    +
    +
    +
  • +
  • +
    + + + + uuidOrUsername + +
    +
    +
    +
    +
    +
    +

    The UUID or username property value if found.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public var uuidOrUsername: String? { return self.uuid ?? self.username }
    + +
    +
    +
    +
    +
  • +
+
+
+ +
    +
  • +
    + + + + init(name:) + +
    +
    +
    +
    +
    +
    +

    Designated initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(name:String? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + name + + +
    +

    The name of the user. Note this is different from the username property.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    The required public initializer for UsergridEntity subclasses.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    required public init(type: String, name: String?, propertyDict: [String : AnyObject]?)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + type + + +
    +

    The type associated with the UsergridEntity object.

    + +
    +
    + + name + + +
    +

    The optional name associated with the UsergridEntity object.

    + +
    +
    + + propertyDict + + +
    +

    The optional property dictionary that the UsergridEntity object will start out with.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new UsergridUser object.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Designated initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public init(name:String,propertyDict:[String:AnyObject]? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + name + + +
    +

    The name of the user. Note this is different from the username property.

    + +
    +
    + + propertyDict + + +
    +

    The optional property dictionary that the UsergridEntity object will start out with.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Convenience initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(name:String, email:String, password:String? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The name of the user. Note this is different from the username property.

    + +
    +
    + + email + + +
    +

    The user’s email.

    + +
    +
    + + password + + +
    +

    The optional user’s password.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
  • +
    + + + + init(email:password:) + +
    +
    +
    +
    +
    +
    +

    Convenience initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(email:String, password:String? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + email + + +
    +

    The user’s email.

    + +
    +
    + + password + + +
    +

    The optional user’s password.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Convenience initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(name:String, username:String, password:String? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The name of the user. Note this is different from the username property.

    + +
    +
    + + username + + +
    +

    The username of the user.

    + +
    +
    + + password + + +
    +

    The optional user’s password.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Convenience initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(username:String, password:String? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + username + + +
    +

    The username of the user.

    + +
    +
    + + password + + +
    +

    The optional user’s password.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Convenience initializer for UsergridUser objects.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public convenience init(name:String?, email:String?, username:String?, password:String? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + name + + +
    +

    The optional name of the user. Note this is different from the username property.

    + +
    +
    + + email + + +
    +

    The optional user’s email.

    + +
    +
    + + username + + +
    +

    The optional username of the user.

    + +
    +
    + + password + + +
    +

    The optional user’s password.

    + +
    +
    +
    +
    +

    Return Value

    +

    A new instance of UsergridUser.

    + +
    +
    +
    +
  • +
+
+
+ +
    +
  • +
    + + + + init(coder:) + +
    +
    +
    +
    +
    +
    +

    NSCoding protocol initializer.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    required public init?(coder aDecoder: NSCoder)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + aDecoder + + +
    +

    The decoder.

    + +
    +
    +
    +
    +

    Return Value

    +

    A decoded UsergridUser object.

    + +
    +
    +
    +
  • +
  • +
    + + + + encodeWithCoder(_:) + +
    +
    +
    +
    +
    +
    +

    NSCoding protocol encoder.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public override func encodeWithCoder(aCoder: NSCoder)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + aCoder + + +
    +

    The encoder.

    + +
    +
    +
    +
    +
    +
  • +
+
+
+ +
    +
  • + +
    +
    +
    +
    +
    +

    Checks the given email and/or username availablity for new UsergridUser objects using the shared instance of UsergridClient.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func checkAvailable(email:String?, username:String?, completion:UsergridUserAvailabilityCompletion)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + email + + +
    +

    The optional email address.

    + +
    +
    + + username + + +
    +

    The optional username.

    + +
    +
    + + completion + + +
    +

    The completion block.

    + +
    +
    +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Checks the given email and/or username availablity for new UsergridUser objects using with the given UsergridClient.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public static func checkAvailable(client: UsergridClient, email:String?, username:String?, completion:UsergridUserAvailabilityCompletion)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + client + + +
    +

    The client to use for checking availability.

    + +
    +
    + + email + + +
    +

    The optional email address.

    + +
    +
    + + username + + +
    +

    The optional username.

    + +
    +
    + + completion + + +
    +

    The completion block.

    + +
    +
    +
    +
    +
    +
  • +
+
+
+ +
    +
  • +
    + + + + create(_:) + +
    +
    +
    +
    +
    +
    +

    Creates the user object in Usergrid if the user does not already exist with the shared instance of UsergridClient.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(completion: UsergridResponseCompletion? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + +
    + + completion + + +
    +

    The optional completion block.

    + +
    +
    +
    +
    +
    +
  • +
  • +
    + + + + create(_:completion:) + +
    +
    +
    +
    +
    +
    +

    Creates the user object in Usergrid if the user does not already exist with the given UsergridClient.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func create(client: UsergridClient, completion: UsergridResponseCompletion? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + +
    + + client + + +
    +

    The client to use for creation.

    + +
    +
    + + completion + + +
    +

    The optional completion block.

    + +
    +
    +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Authenticates the specified user using the provided username and password with the shared instance of UsergridClient.

    + +

    While functionally similar to UsergridClient.authenticateUser(auth), this method does not automatically assign this user to UsergridClient.currentUser:

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func login(username:String, password:String, completion: UsergridUserAuthCompletionBlock? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + +
    + + username + + +
    +

    The username.

    + +
    +
    + + password + + +
    +

    The password.

    + +
    +
    + + completion + + +
    +

    The optional completion block.

    + +
    +
    +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Authenticates the specified user using the provided username and password.

    + +

    While functionally similar to UsergridClient.authenticateUser(auth), this method does not automatically assign this user to UsergridClient.currentUser:

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func login(client: UsergridClient, username:String, password:String, completion: UsergridUserAuthCompletionBlock? = nil)
    + +
    +
    +
    +

    Parameters

    + + + + + + + + + + + + + + + + + + + +
    + + client + + +
    +

    The client to use for login.

    + +
    +
    + + username + + +
    +

    The username.

    + +
    +
    + + password + + +
    +

    The password.

    + +
    +
    + + completion + + +
    +

    The optional completion block.

    + +
    +
    +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    +
    +

    Changes the User’s current password with the shared instance of UsergridClient.

    + +
    +
    +

    Declaration

    +
    +

    Swift

    +
    public func resetPassword(old:String, new:String, completion:UsergridUserResetPasswordCompletion? = nil