convoo/login-fire

Property "inProgress" not up to date on auto sign-in

masonlouchart opened this issue · 2 comments

The "in progress" state is materialized by the property inProgress.

The issue is that the property is updated only inside functions defined in behaviors or elements themself. However, in the case an element automatically signs a user in, none of these methods is called. I guess the process is started by a polymerfire element, so the property is not trustable in this case.

It seems not really easy to solve. The firebase-auth element (that we use to consume to the Firebase Auth API) subscribe to any change of the auth state right after an instance of the client API is available. In this case the last state returned is the user profile connected (excepted if the user has explicitly sign out of course). So login-fire elements bind the user snapshot to their corresponding property.

To have a useful and trustable inProgress property we have to update its value just before attaching the listener on Auth state changes inside firebase-auth.

I see 2 "solutions":

  • stop using firebase-auth element and consume direclty the API (that means re-implement a part of the element)
  • ignore change during a laps of time to enforce the user click on a button or valid the form (that will prevent auto sign-in)

None of both suit to me 😿

Anyone have an idea ❓

What we want is to know when the element is busy to sign an end user in. Because the firebase-auth element goes ahead as soon as it connected to the DOM, we can't inform the user (of our element) at the rigth time.

Considering the previous comment, I suggest to use an attribute auto to define if the element must automaticlaly sign end users in.

If this attribute is false, the first login established by the firebase-auth element has to be ignored. In this case, the end user has to make an action (that will run the normal process and updates the inProgress property as expected).

If the attribute is true, the element initializes the inProgress property to true and leave the rest of the process to the firebase-auth element that will get the user and set back the inProgress property to false.

What do you think about it? Am I understandable?

It has to be test with redirect...