Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing details in the AuthBlockingEvent when using with the Authentication Emulator #8109

Open
vajahath opened this issue Jan 9, 2025 · 1 comment

Comments

@vajahath
Copy link

vajahath commented Jan 9, 2025

[REQUIRED] Environment info

firebase-tools: 13.29.1

Platform: MacOS

[REQUIRED] Test case

This seem to be the Auth emulator bug.

export const onUserSignIn = beforeUserSignedIn(async (event) => {
  const providerData = event.data?.providerData;
  const providerId = event.additionalUserInfo?.providerId;
  const isNewUser = event.additionalUserInfo?.isNewUser;
  const metadata = event.data?.metadata;
  
 console.log(JSON.stringify({providerData, providerId, isNewUser, metadata}));
});

Output:

{
  "providerData": [],
  "providerId": "google.com",
  "isNewUser": false,
  "metadata": {
    "creationTime": "Invalid Date",
    "lastSignInTime": "Invalid Date"
  }
}

[REQUIRED] Steps to reproduce

  • I anonymously signed in the user
  • Then I converted the user to google signed in user.
export const onUserSignIn = beforeUserSignedIn(async (event) => {
  const providerData = event.data?.providerData;
  const providerId = event.additionalUserInfo?.providerId;
  const isNewUser = event.additionalUserInfo?.isNewUser;
  const metadata = event.data?.metadata;
  
 console.log(JSON.stringify({providerData, providerId, isNewUser, metadata}));
});

[REQUIRED] Expected behavior

  1. providerData shouldn't be empty (see providerId, so that information seem missing in providerData)
  2. creationTime and lastSignInTime are invalid - it should be actual Date.

[REQUIRED] Actual behavior

{
  "providerData": [],
  "providerId": "google.com",
  "isNewUser": false,
  "metadata": {
    "creationTime": "Invalid Date",
    "lastSignInTime": "Invalid Date"
  }
}
@colerogers
Copy link
Contributor

Hey @vajahath thanks for opening this issue!

I did some digging and it looks like the provider data isn't being sent from Auth emulator and both the creationTime and lastSignInTime being sent are string representations of milliseconds since Epoch. In the Functions SDK we convert these times using new Date() here. Since those are treated as strings and not numbers, the output is Invalid Date. The Auth emulator needs to be patched to correctly send them as numbers so the SDK can parse them. I'll re-assign this issue so they can take a look.

@colerogers colerogers assigned malcolmdeck and unassigned colerogers Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants