Accounts
reaction-core的用户存在users表和Accounts表,下面是初始化Reaction后得到的Owner用户表结构。 用户与业务有关的信息存在Accounts表中,其余的放在了users表中, server/methods/accounts.js:Accounts.onCreateUser()可以看到 Accounts中的用户是首先clone Meteor user,然后在上面添加新属性后insert到Accounts表中。 这里users中的用户作用有两个:
-
基于Meteor accounts包管理用户的注册、验证、登录等动作;
-
基于alanning/meteor-roles定义用户角色;
下面是从数据库中得到的一组实例:
> db.users.find().pretty()
{
"_id" : "Jyt46yndz8e5tCWgN",
"createdAt" : ISODate("2015-10-06T03:43:17.711Z"),
"services" : {
"password" : {
"bcrypt" : "$2a$10$Oj.qa9YmYdQazg3WkvqlbOf2FM2.SI5V0a6Ar8kW8qGEc.dRhzHXe"
}
},
"username" : "Owner",
"emails" : [
{
"address" : "asy6nklv@localhost",
"verified" : false,
"provides" : "default"
}
],
"roles" : {
"8jbLoDao7BaLhmCog" : [
"guest",
"account/profile",
"owner",
"admin",
"dashboard",
"dashboard/settings/shop",
"dashboard/orders",
"createProduct",
"dashboard/accounts",
"core",
"shipping",
"reaction-shipping",
"paypal",
"reaction-paypal",
"braintree",
"reaction-braintree",
"stripe",
"reaction-stripe",
"authnet",
"reaction-auth-net",
"social",
"reaction-social",
"reactionAnalytics",
"reaction-analytics"
],
"__global_roles__" : [
"owner",
"admin",
"dashboard"
]
}
}
> db.Accounts.find().pretty()
{
"_id" : "Jyt46yndz8e5tCWgN",
"createdAt" : ISODate("2015-10-06T03:43:17.733Z"),
"emails" : [
{
"address" : "asy6nklv@localhost",
"verified" : false,
"provides" : "default"
}
],
"userId" : "Jyt46yndz8e5tCWgN",
"shopId" : "8jbLoDao7BaLhmCog",
"acceptsMarketing" : false,
"state" : "new"
}