simple schema - Meteor Error: User Not Found -


i have been working on extending meteor.users schema work fine after create first user in meteor.startup() , tried logging in "user not found" error. though can see user in mongo shell. here schema:

    schemas.user = new simpleschema({     username: {         type: string,         optional: true     },     emails: {         type: array,         optional: true     },     "emails.$": {         type: object     },     "emails.$.address": {         type: string,         regex: simpleschema.regex.email     },     "emails.$.verified": {         type: boolean     },     createdat: {         type: date,         optional: true     },     "firstname":{      type: string,      max: 50,      min:2      },     'middlename':{     type: string,     optional: true,     max: 50     },     "lastname":{      type: string,      max: 50,      min:2     },     "gender": {     type: string,     autoform: {       affieldinput: {type: "select-radio-inline",},       options:        [          {label: "male", value: "male"},          {label: "female", value: "female"}        ]     }     },    "branch": {       type: string,       optional: true,       autoform: {         type: "select",         options: function () {             return companybranches.find().map(function (c) {                 return {label: c.companyname+' - '+c.addresscity, value: c._id};             });         }     }     },     "active":{     type: string,     allowedvalues: ["yes","no"],     autoform: {       options: [         {label: "yes", value: "yes"},         {label: "no", value: "no"}       ],       affieldinput: {        type: "select-radio-inline"       }     }   },     services: {         type: object,         optional: true,         blackbox: true     },     roles: {         type: [string],         optional: true,         autoform: {           options: [             {label: "dashboard", value: "dashboard"},             {label: "branches", value: "branches"},             {label: "user profile", value: "user profile"},             {label: "case managers", value: "case managers"},             {label: "insurance company", value: "insurance company"},             {label: "tasks", value: "tasks"},             {label: "calendar", value: "calendar"},             {label: "contacts", value: "contacts"},             {label: "cases", value: "cases"},             {label: "requests", value: "requests"},             {label: "accounts", value: "accounts"},             {label: "reports", value: "reports"},             {label: "search", value: "search"},             {label: "hr", value: "hr"}           ],           affieldinput: {            type: "select-checkbox-inline"           }         }     }     });      meteor.users.attachschema(schemas.user); 

this meteor startup function:

meteor.startup(function () { if ( meteor.users.find().count() === 0 ) {    accounts.createuser({          username: "leocrawf@gmail.com",         email:"leocrawf@gmail.com",         password: "leoten",         firstname: "leocrawf",         lastname: "stewart",         gender:"male",         active: "yes"       }, function (error) {         if (error) {           console.log("cannot create user");         }       });     } }); 

on server doing in accounts.oncreateuser():

accounts.oncreateuser(function(options, user) {         user = options || {};         user.username = options.username;         user.firstname = options.firstname;         user.lastname  = options.lastname;            user.active    = options.active;         user.gender    = options.gender;         // returns user object         return user;     }); 

when query mongo shell this:

meteor:primary> db.users.find().pretty() { "_id" : "pfurr8idywjcx9rus", "username" : "leocrawf@gmail.com", "firstname" : "leocrawf", "lastname" : "stewart", "gender" : "male", "active" : "yes", "services" : {     "resume" : {      "logintokens" : [             {     "when" : isodate("2016-02-05t23:13:38.364z"),     "hashedtoken" : "vs5xvlkl59yvto/fbkbsnar38i8ilaruj2w1yecq2io="             }         ]      }    }  } 

it doesn't you're setting profile correctly when creating user:

instead of:

accounts.createuser({    username: "leocrawf@gmail.com",   email:"leocrawf@gmail.com",   password: "leoten",   firstname: "leocrawf",   lastname: "stewart",   gender:"male",   active: "yes" }, 

try:

accounts.createuser({    username: "leocrawf@gmail.com",   email: "leocrawf@gmail.com",   password: "leoten",   profile: {     firstname: "leocrawf",     lastname: "stewart",     gender: "male",     active: "yes"   } }, 

also recommend active: true instead of active: "yes" use boolean instead of string. doesn't you've defined active or gender in schema either btw.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -