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
passwordThe password to be validated.
passwordPolicyThe 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
userIdUser identifier.
recipientTypeRecipient type.
completionCompletion 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
PasswordManagerclass before calling this method.Throws
Throws:
passwordValidationGenericoldPasswordInvalidpasswordHistroyPolicyNotMetgeneric
Declaration
Swift
public static func changePassword(oldPassword: String, newPassword: String, policyValidation: Bool = true, completion: @escaping (NSError?) -> Void)Parameters
oldPasswordThe old password.
newPasswordThe new password.
policyValidationWhether to validate the password policy before sending the request to server.
completionCompletion 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
validatePasswordmethod of thePasswordManagerclass before calling this method.Throws
Throws:
passwordValidationGenericpasswordHistroyPolicyNotMetgeneric
Declaration
Swift
public static func resetPassword(userId: String, newPassword: String, session: String = "", policyValidation: Bool = true, completion: @escaping (NSError?) -> Void)Parameters
userIdThe user identifer.
newPasswordA new password.
sessionThe session ID for the OTP.
policyValidationWhether to validate the password policy before sending the request to server.
completionCompletion 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)
PasswordManager Class Reference