流星用户帐户 - OnSignin

时间:2016-02-09 02:39:46

标签: meteor user-accounts

我已将模式更改为包含子模式。我想将相关数据组合在一起,使其更易于管理。不幸的是,这破坏了我的注册程序。如何使autoform将firstName插入子模式。有什么想法吗?

路径:at_config.js

AccountsTemplates.addFields([
    {        
        _id: "details.firstName",
        type: 'text',
        displayName: "First name",
        required: true,
        minLength: 1,
        maxLength: 37
    }
]); 

路径:Schema.js

AccountsTemplates.configure({

Schema.UserDetails = new SimpleSchema({
    firstName: {
        type: String,
        optional: false
    }
});

Schema.UserProfile = new SimpleSchema({
    details: {
        type: Schema.UserDetails,
        optional: true
    },
});

Schema.User = new SimpleSchema({
    profile: {
        type: Schema.UserProfile,
        optional: true
    }   
});


Meteor.users.attachSchema(Schema.User);

路径:startup.js

Accounts.onCreateUser(function (options, user) {
    if (options.profile && options.profile.roles) {
      //include the user profile
      Roles.setRolesOnUserObj(user, options.profile.roles);
    }

    if (options.profile) {
      // include the user profile
      user.profile = options.profile;
    }

    return user;
  });

0 个答案:

没有答案
相关问题