Meteor Collections schema not allowing Google authentication -


i'm building simple user account using meteorjs. user given option login/register using google. if registering first time, users prompted fill out profile information after authenticating user account.

i'm using collections2 manage schema user account , attaching meteor.users, seen here:

var schemas = {};   schemas.userprofile = new simpleschema({     firstname: {         type: string,         regex: /^[a-za-z-]{2,25}$/,         optional: true     },     lastname: {         type: string,         regex: /^[a-za-z]{2,25}$/,         optional: true     },     gender: {         type: string,         allowedvalues: ['male', 'female'],         optional: true     } });   schemas.user = new simpleschema({     username: {         type: string,         regex: /^[a-z0-9a-z_]{3,15}$/     },      _id : {         type: string     },      createdat: {         type: date     },     profile: {         type: object     },     services: {         type: object,         blackbox: true     },     // add `roles` schema if use meteor-roles package.     // option 1: object type     // if specify type object, must specify     // `roles.global_group` group whenever add user role.     // example:     // roles.adduserstoroles(userid, ["admin"], roles.global_group);     // can't mix , match adding , without group since     // fail validation in cases.     //roles: {     //    type: object,     //    optional: true,     //    blackbox: true     //}     // option 2: [string] type     // if sure never need use role groups,     // can specify [string] type     roles: {         type: [string],         optional: true     } });   meteor.users.attachschema(schemas.users); 

when registering account, error:

exception while invoking method 'login' error: when modifier option true, validation object must have @ least 1 operator

i'm new meteor , i'm not sure error means. can't seem find documentation on issue. i've tried modifying meteor.users.allow , meteor.users.deny permissions see if has effect, seems underlying issue way i'm using collections2 package.

update - resolved: 1 typo @ bottom of code causing error:

where have meteor.users.attachschema(schemas.users); should have been meteor.users.attachschema(schemas.user);

also similar @ethaan posted, should have referred schemas.user.profile type profile: { type: schemas.userprofile }

that way, user's profile settings validated based off of userprofile schema, rather being validated object.

it seems 1 of options null or dosnt exists.

createdat,profile,username,services. 

like error says getting validated dosnt exists, example trying validate profile object, there not profile object nothing getting on schema.

when modifier option true

this part because default, keys required. set optional: true. see problem on login/registrato workflow. change option false.

for example, change optional on profile field.

schemas.user = new simpleschema({     username: {         type: string,         regex: /^[a-z0-9a-z_]{3,15}$/     },      _id : {         type: string     },      createdat: {         type: date     },     profile: {         type: object,         optional:false, // example     },     services: {         type: object,         blackbox: true     } }); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -