nilsi nilsi - 1 year ago 94
Android Question

Change password with Firebase for Android

I want to implement change password functionality for my application.

I included

com.google.firebase:firebase-auth:9.0.2
in my
build.gradle
file and so far everything has been working fine until I tried to implement change password functionality.

I found that the
FirebaseUser
object has a
updatePassword
method that takes a new password as the parameter. I could use this method and implement validation myself. However, I need the user's current password for comparing with the inputted one and I can't find a way to get that password.

I also found another method on the
Firebase
object that takes the old password, new password, and a handler. The problem is that I need to also include
com.firebase:firebase-client-android:2.5.2+
to access this class and when I am trying this method I'm getting to following error:


Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/


Feel like I'm missing something here. What's the recommended approach for implementing this? And when to use what dependency?

Answer Source

There is no way to retrieve the current password of a user from Firebase Authentication.

One way to allow your users to change their password is to show a dialog where they enter their current password and the new password they'd like. You then sign in (or re-authenticate) the user with the current passwordand call updatePassword() to update it.