Skip to content

AngularFireAuth idToken emits a string instead of User #1464

Closed
@markstuart

Description

@markstuart

Hi there, thanks for a great library, I've been using it on a large-ish project for a year or so.

I recently upgraded Angular/AngularFire/Firebase in the project and struck an issue with the account creation flow that took me a little while to fathom. It all came down to the change of behaviour of authState in 4.0.0-rc0, due to the underlying change in Firebase's onAuthStateChanged. After finding your changelog entry stating "The added AngularFireAuth.idToken: Observable<firebase.User> behaves as authState used to." I tried using it, but found the signature did not match what I was expecting.

Also, I read your v4 upgrade guide but didn't see any mention of the backward compatible idToken observable.

I have downgraded to AngularFire 5.0.0-rc.0 as a temporary workaround, to get latest version before idToken was altered.

Version info

Angular: 5.2.2

Firebase: 4.9.1

AngularFire: 5.0.0-rc.6

Other (e.g. Ionic/Cordova, Node, browser, operating system):

Expected behavior

idToken would be a drop-in replacement for users upgrading from pre-4.0.0 angularfire2's authState, as described in the changelog

This makes sense as it follows the interface of the firebase library's onIdTokenChanged which returns a nullable firebase.User

Actual behavior

idToken emits the result of the user.getIdToken promise to subscribers. This behaviour appears to have changed in this commit: 8ab3803

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions