Skip to content

Custom Login token handling in auth_backend.ts #292

Description

@ksachdeva
export function authDataToAuthState(authData: firebase.User, providerData?: OAuthCredential): FirebaseAuthState {
  if (!authData) return null;
  let providerId;
  let { uid } = authData;
  let authState: FirebaseAuthState = { auth: authData, uid, provider: null };
  if (authData.isAnonymous) {
    providerId = 'anonymous';
    authState.provider = AuthProviders.Anonymous;
    authState.anonymous = true;
    return authState;
  } else {
    providerId = authData.providerData[0].providerId;
  }

When the custom token is submitted to Firebase at one point we end up here. From what I noticed, the authData.providerData is an array of length 0 and hence
providerId = authData.providerData[0].providerId;

results in undefined error.

I do not know where the fix should be -

a) Should Firebase return providerData & providerId set to "custom" as expected by AngularFire2 ?

or

b) Should AngularFire2 determines that authentication used was custom so there will be no providerData ?

Regards
Kapil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions