Lock iOS: Password Reset

You can allow the user to reset their password for any database connections.

Heads up! This page is documentation for an outdated version of Lock for iOS (version 1). Check out the Lock v1 to Lock v2 migration guide, for information on migrating to v2, or the Lock v2 Documentation.

If you use Lock UI, you can hide or show a Reset password button by setting the disableResetPassword property, which will default to false.

If you implement a custom UI, you need to send a password reset email to the user using A0APIClient.

NOTE: Please see Password Strength in Auth0 Database Connections before implementing password reset.

Important considerations

Passwords can only be changed for users signing in using database connections. If a user is signing in with a social or enterprise connection, their password would need to be reset in those platforms.

Examples

Objective-C

A0Lock *lock = [A0Lock sharedLock];
A0APIClient *client = [lock apiClient];
A0AuthParameters *params = [A0AuthParameters newDefaultParams];
params[A0ParameterConnection] = @"Username-Password-Authentication";
                                // Or your configured DB connection

[client requestChangePasswordForUsername:<user_email>
                              parameters:params
                                 success:^{
                                     NSLog(@"Please check your email!");
                                 } failure:^(NSError * _Nonnull error) {
                                     NSLog(@"Oops something went wrong: %@", error);
                                 }];

Swift

let client = A0Lock.shared().apiClient()
let params = A0AuthParameters.newDefaultParams();
params[A0ParameterConnection] = "Username-Password-Authentication";
// Or your configured DB connection
client.requestChangePassword(forUsername: "<username>", parameters: params,
success: { _ in
    print("Please check your email!")
}, failure: { error in
    print("Oops something went wrong: \(error)")
})