Alex Costantini
Alex Costantini

Reputation: 367

Changing a user's email/password in Firebase 3 for iOS

I'm looking for the new class and methods that replace 'changeEmailForUser' and 'changePasswordForUser' on the Firebase class after today's major update. I assume they're now a part of FIRAuth, but I can't seem to find anything. Can somebody point me in the right direction?

Upvotes: 5

Views: 2367

Answers (1)

JCode
JCode

Reputation: 1878

The docs are a bit confusing but at the bottom of the "Manage Users" section which is under "iOS" which is under "Authentication" which is here

According to the docs, to update a user's email address:

FIRUser *user = [FIRAuth auth].currentUser;

[user updateEmail:@"[email protected]" completion:^(NSError *_Nullable error) {
  if (error) {
    // An error happened.
  } else {
    // Email updated.
  }
}];

and for password:

FIRUser *user = [FIRAuth auth].currentUser;
NSString *newPassword = [yourApp getRandomSecurePassword];

[user updatePassword:newPassword completion:^(NSError *_Nullable error) {
  if (error) {
    // An error happened.
  } else {
    // Password updated.
  }
}];

other important information regarding emails for password resets are all at the link given above.

Upvotes: 8

Related Questions