SKYAuthContainer

@interface SKYAuthContainer : NSObject <SKYAuthResponseDelegateProtocol>

/// Undocumented
@property (nonatomic, readonly) NSString *_Nullable currentUserRecordID;
/// Undocumented
@property (nonatomic, readonly) SKYAccessToken *_Nullable currentAccessToken;
/// Undocumented
@property (nonatomic, readonly) SKYRecord *_Nullable currentUser;
/// Undocumented
@property (nonatomic, readonly) BOOL currentUserVerified;

/**
 Set current user data encryption enable state

 When this is on, current user data will be saved and retrieved from Keychain instead of
 UserDefaults. Default is NO.
 */
- (void)setCurrentUserDataEncryptionEnable:(BOOL)enabled;

/**
 Updates the <currentUserRecordID> and <currentAccessToken>. The updated access credentials are also
 stored in persistent
 storage.

 This method is called when operation sign up, log in and log out is performed using the container's
 convenient
 method and when the operation is completed successfully.
 */
- (void)updateWithUserRecordID:(NSString *_Nullable)userRecordID
                   accessToken:(SKYAccessToken *_Nullable)accessToken;

/**
 Updates the <currentUser> and <currentAccessToken>. The updated access credentials are also
 stored in persistent storage.

 This method is called when operation sign up, log in and log out is performed using the container's
 convenient
 method and when the operation is completed successfully.
 */
- (void)updateWithUser:(SKYRecord *_Nullable)user
           accessToken:(SKYAccessToken *_Nullable)accessToken;

/**
 Set the handler to be called when SKYOperation's subclasses failed to authenticate itself with
 remote server.

 Such circumstance might arise on a container when either:

 1. There are no logged-in users for an opertion that requires users login.
 2. Access token is invalid or has been expired.

 In either cases, developer should prompt for re-authentication of user and login using
 <SKYLoginUserOperation>.

 NOTE: Any attempt to invoke user logout related operation within the set handler will created an
 feedback loop as logouting an invalid access token is also a kind of authentication error.
 */
- (void)setAuthenticationErrorHandler:(void (^_Nullable)(SKYContainer *container,
                                                         SKYAccessToken *_Nullable token,
                                                         NSError *_Nullable error))authErrorHandler;

@end

Undocumented

  • Undocumented

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSString *_Nullable currentUserRecordID;

    Swift

    var currentUserRecordID: String? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (readonly, nonatomic) SKYAccessToken *_Nullable currentAccessToken;

    Swift

    var currentAccessToken: SKYAccessToken? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (readonly, nonatomic) SKYRecord *_Nullable currentUser;

    Swift

    var currentUser: SKYRecord? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL currentUserVerified;

    Swift

    var currentUserVerified: Bool { get }
  • Set current user data encryption enable state

    When this is on, current user data will be saved and retrieved from Keychain instead of UserDefaults. Default is NO.

    Declaration

    Objective-C

    - (void)setCurrentUserDataEncryptionEnable:(BOOL)enabled;

    Swift

    func setCurrentUserDataEncryptionEnable(_ enabled: Bool)
  • Updates the and . The updated access credentials are also stored in persistent storage.

    This method is called when operation sign up, log in and log out is performed using the container’s convenient method and when the operation is completed successfully.

    Declaration

    Objective-C

    - (void)updateWithUserRecordID:(NSString *_Nullable)userRecordID
                       accessToken:(SKYAccessToken *_Nullable)accessToken;

    Swift

    func update(withUserRecordID userRecordID: String?, accessToken: SKYAccessToken?)
  • Updates the and . The updated access credentials are also stored in persistent storage.

    This method is called when operation sign up, log in and log out is performed using the container’s convenient method and when the operation is completed successfully.

    Declaration

    Objective-C

    - (void)updateWithUser:(SKYRecord *_Nullable)user
               accessToken:(SKYAccessToken *_Nullable)accessToken;

    Swift

    func update(withUser user: SKYRecord?, accessToken: SKYAccessToken?)
  • Set the handler to be called when SKYOperation’s subclasses failed to authenticate itself with remote server.

    Such circumstance might arise on a container when either:

    1. There are no logged-in users for an opertion that requires users login.
    2. Access token is invalid or has been expired.

    In either cases, developer should prompt for re-authentication of user and login using .

    NOTE: Any attempt to invoke user logout related operation within the set handler will created an feedback loop as logouting an invalid access token is also a kind of authentication error.

    Declaration

    Objective-C

    - (void)setAuthenticationErrorHandler:
        (void (^_Nullable)(SKYContainer *_Nonnull, SKYAccessToken *_Nullable,
                           NSError *_Nullable))authErrorHandler;

    Swift

    func setAuthenticationErrorHandler(_ authErrorHandler: ((SKYContainer, SKYAccessToken?, Error?) -> Void)?)
  • Undocumented

    Declaration

    Objective-C

    - (void)forgotPasswordWithEmail:(NSString *)emailAddress
                  completionHandler:
                      (void (^_Nullable)(NSDictionary *_Nullable, NSError *_Nullable))completionHandler;

    Swift

    func forgotPassword(withEmail emailAddress: String, completionHandler: (([AnyHashable : Any]?, Error?) -> Void)? = nil)
  • Undocumented

    Declaration

    Objective-C

    - (void)resetPasswordWithUserID:(NSString *)userID
                               code:(NSString *)code
                           expireAt:(long)expireAt
                           password:(NSString *)password
                  completionHandler:
                      (void (^_Nullable)(NSDictionary *_Nullable, NSError *_Nullable))completionHandler;

    Swift

    func resetPassword(withUserID userID: String, code: String, expireAt: Int, password: String, completionHandler: (([AnyHashable : Any]?, Error?) -> Void)? = nil)
  • Request user data verification of the specified record key.

    Declaration

    Objective-C

    - (void)requestVerification:(nonnull NSString *)recordKey
                     completion:
                         (void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func requestVerification(_ recordKey: String, completion completionBlock: ((Error?) -> Void)? = nil)

    Parameters

    recordKey

    The record key to be verified

    completionBlock

    Completion Block

  • Mark a user account as verified by specifying a verification code.

    Declaration

    Objective-C

    - (void)verifyUserWithCode:(nonnull NSString *)code
                    completion:(SKYContainerUserOperationActionCompletion _Nullable)
                                   completionBlock;

    Swift

    func verifyUser(withCode code: String, completion completionBlock: SKYContainerUserOperationActionCompletion? = nil)

    Parameters

    code

    Verification code

    completionBlock

    Completion Block

  • Login user with given provider.

    Declaration

    Objective-C

    - (void)loginOAuthProvider:(nonnull NSString *)providerID
                       options:(nonnull NSDictionary *)options
             completionHandler:(SKYContainerUserOperationActionCompletion _Nullable)
                                   completionHandler;

    Swift

    func loginOAuthProvider(_ providerID: String, options: [AnyHashable : Any] = [:], completionHandler: SKYContainerUserOperationActionCompletion? = nil)
  • Link user with given provider.

    Declaration

    Objective-C

    - (void)linkOAuthProvider:(nonnull NSString *)providerID
                      options:(nonnull NSDictionary *)options
            completionHandler:
                (void (^_Nullable)(NSError *_Nullable))completionHandler;

    Swift

    func linkOAuthProvider(_ providerID: String, options: [AnyHashable : Any] = [:], completionHandler: ((Error?) -> Void)? = nil)
  • Resume current oauth flow with url, need to be called by application:openURL:options: in appDelegate

    Declaration

    Objective-C

    - (BOOL)
    resumeOAuthFlow:(nonnull NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *_Nullable)
                        options;

    Swift

    func resumeOAuthFlow(_ url: URL, options: [UIApplicationOpenURLOptionsKey : Any]? = nil) -> Bool
  • Login user with given provider by access token.

    Declaration

    Objective-C

    - (void)loginOAuthProvider:(nonnull NSString *)providerID
                   accessToken:(nonnull NSString *)accessToken
             completionHandler:(SKYContainerUserOperationActionCompletion _Nullable)
                                   completionHandler;

    Swift

    func loginOAuthProvider(_ providerID: String, accessToken: String, completionHandler: SKYContainerUserOperationActionCompletion? = nil)
  • Link user with given provider by access token.

    Declaration

    Objective-C

    - (void)linkOAuthProvider:(nonnull NSString *)providerID
                  accessToken:(nonnull NSString *)accessToken
            completionHandler:
                (void (^_Nullable)(NSError *_Nullable))completionHandler;

    Swift

    func linkOAuthProvider(_ providerID: String, accessToken: String, completionHandler: ((Error?) -> Void)? = nil)
  • Unlink given provider.

    Declaration

    Objective-C

    - (void)unlinkOAuthProvider:(nonnull NSString *)providerID
              completionHandler:
                  (void (^_Nullable)(NSError *_Nullable))completionHandler;

    Swift

    func unlinkOAuthProvider(_ providerID: String, completionHandler: ((Error?) -> Void)? = nil)
  • Get oauth provider user profiles, the result dictionary key is provider id and value is profile dictionary.

    Declaration

    Objective-C

    - (void)getOAuthProviderProfilesWithCompletionHandler:
        (void (^_Nullable)(NSDictionary *_Nullable,
                           NSError *_Nullable))completionHandler;

    Swift

    func getOAuthProviderProfiles(completionHandler: (([AnyHashable : Any]?, Error?) -> Void)? = nil)
  • Login the user with a custom token.

    The custom token is typically created on an external server hosting a user database. This server generates the custom token so that the user on an external server can log in to Skygear Server.

    Declaration

    Objective-C

    - (void)loginWithCustomToken:(nonnull NSString *)customToken
               completionHandler:
                   (SKYContainerUserOperationActionCompletion _Nullable)
                       completionHandler;

    Swift

    func login(withCustomToken customToken: String, completionHandler: SKYContainerUserOperationActionCompletion? = nil)
  • Defines roles to have special powers

    Declaration

    Objective-C

    - (void)defineAdminRoles:(nonnull NSArray<SKYRole *> *)roles
                  completion:(void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func defineAdminRoles(_ roles: [SKYRole], completion completionBlock: ((Error?) -> Void)? = nil)
  • Sets default roles for new registered users

    Declaration

    Objective-C

    - (void)setUserDefaultRole:(nonnull NSArray<SKYRole *> *)roles
                    completion:
                        (void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func setUserDefaultRole(_ roles: [SKYRole], completion completionBlock: ((Error?) -> Void)? = nil)
  • Get roles of users

    Declaration

    Objective-C

    - (void)
    fetchRolesOfUsers:(nonnull NSArray<SKYRecord *> *)users
           completion:(void (^_Nullable)(
                          NSDictionary<NSString *, NSArray<SKYRole *> *> *_Nullable,
                          NSError *_Nullable))completionBlock;

    Swift

    func fetchRoles(ofUsers users: [SKYRecord], completion completionBlock: (([String : [SKYRole]]?, Error?) -> Void)? = nil)

    Parameters

    users

    Target users

    completionBlock

    Completion Block, with a user-to-roles dictionary

  • Get roles of users

    Declaration

    Objective-C

    - (void)
    fetchRolesOfUsersWithUserIDs:(nonnull NSArray<NSString *> *)userIDs
                      completion:(void (^_Nullable)(
                                     NSDictionary<NSString *, NSArray<NSString *> *>
                                         *_Nullable,
                                     NSError *_Nullable))completionBlock;

    Swift

    func fetchRolesOfUsers(withUserIDs userIDs: [String], completion completionBlock: (([String : [String]]?, Error?) -> Void)? = nil)

    Parameters

    userIDs

    Target user

    completionBlock

    Completion Block, with a user-to-roles dictionary

  • Assign roles to users

    Declaration

    Objective-C

    - (void)assignRoles:(nonnull NSArray<SKYRole *> *)roles
                toUsers:(nonnull NSArray<SKYRecord *> *)users
             completion:(void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func assign(_ roles: [SKYRole], toUsers users: [SKYRecord], completion completionBlock: ((Error?) -> Void)? = nil)

    Parameters

    roles

    Roles to be assigned

    users

    Target users

    completionBlock

    Completion Block

  • Assign roles to users

    Declaration

    Objective-C

    - (void)assignRolesWithNames:(nonnull NSArray<NSString *> *)roleNames
                  toUsersWithIDs:(nonnull NSArray<NSString *> *)userIDs
                      completion:
                          (void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func assignRoles(withNames roleNames: [String], toUsersWithIDs userIDs: [String], completion completionBlock: ((Error?) -> Void)? = nil)

    Parameters

    roleNames

    Roles to be assigned

    userIDs

    Target users

    completionBlock

    Completion Block

  • Revoke roles from users

    Declaration

    Objective-C

    - (void)revokeRoles:(nonnull NSArray<SKYRole *> *)roles
              fromUsers:(nonnull NSArray<SKYRecord *> *)users
             completion:(void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func revokeRoles(_ roles: [SKYRole], fromUsers users: [SKYRecord], completion completionBlock: ((Error?) -> Void)? = nil)

    Parameters

    roles

    Roles to be revoked

    users

    Target users

    completionBlock

    Completion Block

  • Revoke roles from users

    Declaration

    Objective-C

    - (void)revokeRolesWithNames:(nonnull NSArray<NSString *> *)roleNames
                fromUsersWihtIDs:(nonnull NSArray<NSString *> *)userIDs
                      completion:
                          (void (^_Nullable)(NSError *_Nullable))completionBlock;

    Swift

    func revokeRoles(withNames roleNames: [String], fromUsersWihtIDs userIDs: [String], completion completionBlock: ((Error?) -> Void)? = nil)

    Parameters

    roleNames

    Roles to be revoked

    userIDs

    Target users

    completionBlock

    Completion Block

  • Enable user account of a disabled user.

    Declaration

    Objective-C

    - (void)adminEnableUserWithUserID:(nonnull NSString *)userID
                           completion:(void (^_Nullable)(NSString *_Nonnull,
                                                         NSError *_Nullable))
                                          completionBlock;

    Swift

    func adminEnableUser(withUserID userID: String, completion completionBlock: ((String, Error?) -> Void)? = nil)

    Parameters

    userID

    User ID of a disabled user

    completionBlock

    Completion Block

  • Disable user account of a user.

    Declaration

    Objective-C

    - (void)adminDisableUserWithUserID:(nonnull NSString *)userID
                               message:(NSString *_Nullable)message
                                expiry:(NSDate *_Nullable)expiry
                            completion:(void (^_Nullable)(NSString *_Nonnull,
                                                          NSError *_Nullable))
                                           completionBlock;

    Swift

    func adminDisableUser(withUserID userID: String, message: String?, expiry: Date?, completion completionBlock: ((String, Error?) -> Void)? = nil)

    Parameters

    userID

    User ID of user to disable

    message

    Message to be shown to user, to explain why the account is disabled, optional

    expiry

    Date and time when the disable user account is automatically enabled, optional

    completionBlock

    Completion Block