trusktr
September 14, 2025, 9:10pm
1
I opened a bug report for it here:
opened 08:52PM - 14 Sep 25 UTC
## Problem:
When using packages like `accounts-google`, APIs like `Accounts.fin… dUserByEmail(email)` do not work.
Presumably, this is because when signed up with Google for example, `Meteor.user().emails` is empty, but `Meteor.user().services.google.email` is populated with the user email instead.
## Reproduction
- add `accounts-google`
- sign up with the "Sign in with Google" button
- On backend, run `Accounts.findUserByEmailTmp(email)` with the email of the Google account
- Notice that the result will be `undefined` despite that the user with the given email address signed up.
## Solution
All of Meteor's user and email APIs should be updated so that emails for a user live in a standardized location (`Meteor.user().emails`) regardless of how the user signed up (email+password, or Oauth with Google/Facebook/etc).
## Workaround
To fix this locally, we can write an `Accounts.onCreateUser` handler in our app to manually map the oauth email to the `user.emails` field.
Basically when signing up with oauth (f.e. Google via the accounts-google package), then user.emails will be undefined. We can fix this in Meteor APIs directly. Ideally all user emails will be stored in the same location regardless of how they signed up.
Last time I used something which was not passwordless:
{
"_id": "5pjYG9WSBGmyN2vJp",
"createdAt": {
"$date": "2019-09-21T09:14:06.554Z"
},
"services": {
"google": {
"accessToken": "ya29.GluKB4a9Kqk2EBJ-Hyg56...",
"idToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ij...",
"scope": [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
"openid"
],
"expiresAt": {
"$numberLong": "1569060846114"
},
"id": "104871879761794918950",
"email": "xxx@gmail.com",
"verified_email": true,
"name": "vxxx xxxxndii",
"given_name": "xxxx",
"family_name": "xxxxxi",
"picture": "https://lh4.googleusercontent.com/-0Z64kPEx6Dg/AAAA....jpg",
"locale": "en",
"refreshToken": "1/sg737AOX41IaCHVlodZHIlsgd9ZALy..."
},
"resume": {
"loginTokens": []
}
},
"emails": [
{
"address": "xxx@gmail.com",
"verified": true
}
],
...
}
I think any updates in this area require updated (for compatibility) packages such as these: Accounts-merge vs. accounts-meld
Not sure if account merging has ever made it to core Meteor, but it should probably stay right there.