I am using passport authentication plugin for KeystoneJS in my project.
Everything works fine if the user account exists and is tied to the used social network. However, when creating a new user with the 'auto create user': true configuration option, I get a 500 error on the oauth callback route. The log indicates a validation error.
ValidationError: Validation failed at model.Document.invalidate (/app/node_modules/keystone/node_modules/mongoose/lib/document.js:1021:32) at /app/node_modules/keystone/node_modules/mongoose/lib/document.js:970:16 at validate (/app/node_modules/keystone/node_modules/mongoose/lib/schematype.js:610:7) at /app/node_modules/keystone/node_modules/mongoose/lib/schematype.js:627:9 at Array.forEach (native) at SchemaString.SchemaType.doValidate (/app/node_modules/keystone/node_modules/mongoose/lib/schematype.js:614:19) at /app/node_modules/keystone/node_modules/mongoose/lib/document.js:968:9 at process._tickCallback (node.js:419:13)
What could be the reason for this?
Edit
User Model:
var keystone = require('keystone'), Types = keystone.Field.Types, social = require('keystone-social-login'); var User = new keystone.List('User'); User.add({ name: { type: Types.Name, required: true, index: true }, email: { type: Types.Email, initial: true, required: true, index: true }, password: { type: Types.Password, initial: true, required: true } }, 'Permissions', { userLevel: { type: Types.Select, options: 'user, business, admin', default: 'user', initial: true } });
Steve source share