PasswordManager

@objc
public class PasswordManager : NSObject

A class that can be used for getting the account and password policy and validate password policy.

  • Validates the password against the current password policy and returns a list of validation errors.

    Declaration

    Swift

    public static func validatePassword(_ password: String, passwordPolicy: PasswordPolicy) -> [NSError]
    Parameters
    password

    The password to be validated.

    passwordPolicy

    The password policy.

    Return Value

    The list of validation errors if any.

  • Forgot Password Request.

    Declaration

    Swift

    public static func forgotPassword(userId: String,
                                      recipientType: IdType,
                                      completion: @escaping (OTPSession?, NSError?) -> Void)
    Parameters
    userId

    User identifier.

    recipientType

    Recipient type.

    completion

    Completion block to be called after forgot password request is complete or errors occured.

  • Change the current user’s password using the old password.

    Note

    This method will validate the password according to the password policy and might fail with a list of validation errors. You can also do the password validation using the PasswordManager class before calling this method.

    Throws

    Throws:

    • passwordValidationGeneric
    • oldPasswordInvalid
    • passwordHistroyPolicyNotMet
    • generic
    Declaration

    Swift

    public static func changePassword(oldPassword: String,
                                      newPassword: String,
                                      policyValidation: Bool = true,
                                      completion: @escaping (NSError?) -> Void)
    Parameters
    oldPassword

    The old password.

    newPassword

    The new password.

    policyValidation

    Whether to validate the password policy before sending the request to server.

    completion

    Completion block to be called after password change is complete or errors occured.

  • Reset the current user’s password using a session ID acquired from an OTP code verification.

    Note

    This method will validate the password according to the server’s password policy and might fail with a list of validation errors. You can also use the validatePassword method of the PasswordManager class before calling this method.

    Throws

    Throws:

    • passwordValidationGeneric
    • passwordHistroyPolicyNotMet
    • generic
    Declaration

    Swift

    public static func resetPassword(userId: String,
                                     newPassword: String,
                                     session: String = "",
                                     policyValidation: Bool = true,
                                     completion: @escaping (NSError?) -> Void)
    Parameters
    userId

    The user identifer.

    newPassword

    A new password.

    session

    The session ID for the OTP.

    policyValidation

    Whether to validate the password policy before sending the request to server.

    completion

    Completion block to be called after password change is complete or errors occured.

  • Fetch the password policy from server.

    Declaration

    Swift

    public static func fetchPasswordPolicy(completion: @escaping (PasswordPolicy?, NSError?) -> Void)