5

プロジェクトで KeystoneJSの Passport 認証プラグインを使用しています。

ユーザー アカウントが存在し、使用されているソーシャル ネットワークに関連付けられていれば、すべてうまく機能します。ただし、config オプションを使用して新しいユーザーを作成すると'auto create user': true、oauth コールバック ルートで 500 エラーが発生します。ログには、検証エラーであることが示されています。

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)

何が原因でしょうか?


編集

ユーザーモデル:

var keystone = require('keystone'),
Types = keystone.Field.Types,
social = require('keystone-social-login');

/**
 * User Model
 * ==========
 */

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 }
});

// Provide access to Keystone
User.schema.virtual('canAccessKeystone').get(function() {
    return this.userLevel === 'admin';
});


/**
 * Registration
 */

social.plugin(User);

User.defaultColumns = 'name, email, userLevel';
User.register();
4

0 に答える 0