dpa99c / cordova-plugin-firebasex

Cordova plugin for Google Firebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin needs to expose an IDTokenDidChangeListener to capture new tokens

doginthehat opened this issue · comments

commented

Feature request

The current implementation of the plugin has a method registerAuthStateChangeListener which exposes an authStateDidChangeListener via internal -addAuthStateDidChangeListener:.

The documentation for this event handlers specifies:

Registers a block as an “auth state did change” listener. To be invoked when:

The block is registered as a listener,
A user with a different UID from the current user has signed in, or
The current user has signed out.

However this does not trigger when a user token is auto refreshed.

This seems to require an IDTokenDidChangeListener.

The documentation for the method to add a hander addIDTokenDidChangeListener: states:

Registers a block as an “ID token did change” listener. To be invoked when:

The block is registered as a listener,
A user with a different UID from the current user has signed in,
The ID token of the current user has been refreshed, or
The current user has signed out.

It's basically the same as auth state but with the extra token refresh.

And unfortunately, without this handler, it's not possible to detect that a user token has been automatically refreshed.

There's a very similar issue with the web sdk that has two separate handlers.

The plugin could expose a registerIDTokenDidChangeListener method that would work fairly similar to the existing auth state listener. Both handlers have similar signatures so would likely be just duplicating the existing functionality with different method signatures.

This has been implemented - documentation for the new method is here