-1

This is how i am changing the email id of current user

        FirebaseUser user = mAuth.getCurrentUser();
        user.updateEmail(email).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
            }
        });

It is working fine

Now i want to change email id of another user(other then the current user) i have the UID of that user

is it possible ?

Shaifali Rajput
  • 1,279
  • 12
  • 30
  • 1
    I think you need to [link the different emails](https://firebase.google.com/docs/auth/android/account-linking) by signing in with one credential and then linking to another. I'm not certain about email->email. – James Poag Oct 23 '18 at 10:08
  • thanks @JamesPoag , i used this link to link the accounts and here i want to change the email – Shaifali Rajput Oct 23 '18 at 10:12
  • If you're storing the email in your database, then it can be done without any security risk and no need for Firebase Admin SDK, but other than that @Frankvanpuffelen said it. – PradyumanDixit Oct 23 '18 at 11:33
  • @PradyumanDixit no , i don't want to change in the database i want to change i n the authentication section . – Shaifali Rajput Oct 23 '18 at 11:51
  • Then when you update email you need to reauthenticate user – Piyush Oct 23 '18 at 11:51
  • @Piyush then i will have new UID, and it will be difficult for me to connect the previous UID data to the new UID – Shaifali Rajput Oct 23 '18 at 12:02
  • Before mark negative vote to the question , please try to understand the question – Shaifali Rajput Oct 23 '18 at 12:03
  • @ShaifaliRajput I m not downvoting. But if you want to update email user without logged in that will be a security risk. – Piyush Oct 23 '18 at 12:05
  • no @Piyushke i am saying this to all, – Shaifali Rajput Oct 23 '18 at 12:18
  • _is it possible_ ? By you. So here everyone gave their opinion. Specially Frank van Puffelen .. So @Shaifali Rajput would you like to update email of user on risk ? – Piyush Oct 23 '18 at 12:26

1 Answers1

2

Changing the email address for a user that is currently not logged into Firebase Authentication can only be done through the Firebase Admin SDK. If this was possible in the Android SDK based on just the UID of the user, that would be a serious security risk (as UIDs are not an authentication mechanism).

For an example of updating an email address through the admin SDK, see updating a user.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807