I saw few similar questions but any of the solutions didn’t help me.So basically i want to change my email and password in authentication when the user is already logged.
I tried to use the methods updateEmail/password but its didn’t changed anything.
Here example of code that i wrote:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.updateEmail(NewEmail)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "User email address updated.");
}
}
});
(the variable ‘NewEmail’ its the email that the user decide to change and then its should to change the email in authentication)
The problem is in that case that its show me line on the ‘updateEmail’ like its tell me that the method is not work of something like that,and all what i tried didn’t worked.
And about how to change the password i tried the same way(the code from the site of firebase authentication) it was without the line on ‘updatepassword’ like in the email method,but its didn’t changed the password and when the user need to log in again its required the previous password(the first password that the user registered with).
If someone has any solution please help me!Thanks:)
2
Answers
If the task is not successful, there’s an exception in there that explain why it failed – but your code is not handling that case. To figure out the root cause of the problem:
If you’re seeing a line through the updateEmail method in your IDE (like Android Studio), it typically indicates that the method is deprecated. However, as of my last update, updateEmail is a valid method for a FirebaseUser in Firebase Authentication. The line might instead suggest an error or a warning. Ensure that you’re using the latest version of the Firebase Authentication library in your build.gradle file:
Replace latest_version with the actual latest version number. You can find this on the Firebase documentation or the Firebase section on MVNRepository.
Ensure that your user is indeed logged in before calling updateEmail, as it requires a recent login. If the user’s authentication state is too old, you might need to re-authenticate the user before making this call.
Updating Password
Re-authentication