Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 779
Alex Costantini Avatar asked May 19 '16 03:05

Alex Costantini


1 Answers

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.

like image 152
JCode Avatar answered Sep 30 '22 22:09

JCode