Amadeu Andrade Amadeu Andrade - 1 year ago 152
iOS Question

How to verify user's current password when changing password on Firebase 3?

I want the user to insert the current password and the new one when updating his password.

I've searched Firebase documentation and didn't find a way to verify the user's current password.

Does anyone know if this is possible?

Answer Source

You will be able to achieve it using reauthenticate before changing the password.

let user = FIRAuth.auth()?.currentUser
let credential = FIREmailPasswordAuthProvider.credentialWithEmail(email, password: currentPassword)    

user?.reauthenticateWithCredential(credential, completion: { (error) in
    if error != nil{
        self.displayAlertMessage("Error reauthenticating user")
    }else{
        //change to new password
    }
})

Just for add more information, here you can find how to set the credential object for whatever provider you are using.