0

I'm trying to setup a password reset within an app using swift 2 and Firebase.

Following Firebases example:

let ref = Firebase(url: "https://<YOUR-FIREBASE-APP>.firebaseio.com")
ref.changePasswordForUser("bobtony@example.com", fromOld: "correcthorsebatterystaple",
toNew: "batteryhorsestaplecorrect", withCompletionBlock: { error in

    if error != nil {
        // There was an error processing the request
    } else {
        // Password changed successfully
    }
})

How can I access an authenticated users email & password in order to pass those values to this function instead of the current mock data?

I'm not interested in sending a temporary password in a pass reset email.

I was thinking that I'd be able to access these values by something like:

let ref = Firebase(url: firebaseURL)

ref.authData.providerData.someValueHere

But I haven't been able to figure it out.

How can I access these values from the currently authenticated user?

ChristianF
  • 1,735
  • 4
  • 28
  • 56

1 Answers1

2

How can I access an authenticated users email & password

Firebase does not store the user's password. Instead it stores a hash of the user's password. That means that there is no API from Firebase that returns a user's password.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • So how do I make use of changePasswordForUser? Which seems to take an email, old password and new password as parameters? – ChristianF Mar 18 '16 at 05:25
  • `changePasswordForUser()` is for the user to change their password in your app. If the user has forgotten their password, you need to use `resetPasswordForUser()`, which sends a password reset email. There currently is no API to change/reset the password without either knowing the current password or sending an email. – Frank van Puffelen Mar 18 '16 at 14:25