splendido / meteor-accounts-emails-field

A Meteor package to keep user.email up to date with email addresses used for 3rd-party account services
19 stars 9 forks source link

Compatibility with aldeed:collection2 #39

Closed steph643 closed 9 years ago

steph643 commented 9 years ago

After installing your package, I get the following serve-side error when logging-in:

I20150407-22:50:02.670(2)? Exception in onLogin callback: Error: When the modifier option is true, validation object must have at least one operator
I20150407-22:50:02.670(2)?     at checkModifier (packages/aldeed:simple-schema/simple-schema-validation.js:271:1)
I20150407-22:50:02.670(2)?     at doValidation1 (packages/aldeed:simple-schema/simple-schema-validation.js:321:1)
I20150407-22:50:02.671(2)?     at doValidation (packages/aldeed:simple-schema/simple-schema-context.js:9:1)
I20150407-22:50:02.671(2)?     at SimpleSchemaValidationContext.simpleSchemaValidationContextValidate [as validate] (packages/aldeed:simple-schema/simple-schema-context.js:44:1)
I20150407-22:50:02.671(2)?     at [object Object].doValidate (packages/aldeed:collection2/collection2.js:317:1)
I20150407-22:50:02.671(2)?     at [object Object].Mongo.Collection.(anonymous function) [as update] (packages/aldeed:collection2/collection2.js:154:1)
I20150407-22:50:02.671(2)?     at updateEmails (packages/splendido:accounts-emails-field/lib/accounts-emails-field.js:142:1)
I20150407-22:50:02.672(2)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
I20150407-22:50:02.672(2)?     at packages/meteor/dynamics_nodejs.js:121:1
I20150407-22:50:02.672(2)?     at packages/accounts-base/accounts_server.js:87:1

My guess is that you are trying to write your registered_emails field and that it conflicts with my Meteor.users schema (which looks like this). Before I investigate further, can you please tell me if this is a know issue? Hopefully with a know workaround?

steph643 commented 9 years ago

I solved this (for now) by adding the following line to my schema:

registered_emails: { type: [Object], blackbox: true, optional: true }
splendido commented 9 years ago

@steph643 I'd say there's nothing in your error for which accounts-emails-field is responsible for...

As you already discovered, it's the schema validation which is failing and you have to patch it ;-)

steph643 commented 9 years ago

Yes, thank you.

At this occasion, I felt some information is missing. Maybe you could add something like this to the doc:

The registered_emails field which is added to the Meteor.users collection has the same format than the built-in emails field (as described in the Meteor documentation):

registered_emails: [
    { address: "cool@example.com", verified: true },
    { address: "another@different.com", verified: false }
  ],

If you use aldeed:collection2 with Meteor.users, you need to add the registered_emails field to your schema:

registered_emails: { type: [Object], blackbox: true, optional: true }
splendido commented 9 years ago

Yeah, would be useful!

Could you please make a PR for this?