如何在meteor上创建默认用户? [英] How to create a default user on meteor?
本文介绍了如何在meteor上创建默认用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果没有用户存在,我想创建一个管理员用户.我在服务器文件夹内的一个js文件上试了一下
I want to create an admin user if no users exist. I tried it on a js file inside the server folder
Meteor.startup(function () {
if(!Meteor.users.find().count()) {
var options = {
username: 'admin',
password: 'default-password',
email: 'admin@example.com'
};
Accounts.createUser(options);
}
});
这是meteor在控制台显示的错误
This is the error that meteor show on the console
Error
at app/packages/livedata/livedata_common.js:143:26
at /Users/camilo/Documents/Proyectos/IM/interno/.meteor/local/build/server/server.js:282:7
at Array.forEach (native)
at Function._.each._.forEach (/Users/camilo/.meteorite/meteors/meteor/meteor/0ffea1c4c308ed24906984f99b13b8fca5a0956c/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
at run (/Users/camilo/Documents/Proyectos/IM/interno/.meteor/local/build/server/server.js:227:7)
=> Exited with code: 1
我做错了什么还是这是一个流星虫?
I'm doing something wrong or this is a meteor bug?
我使用的是meteor 0.6.1 和node.js 0.9.9
I'm using meteor 0.6.1 and node.js 0.9.9
推荐答案
一段时间后,我用meteor 0.6.4再次测试了上面的代码,没有问题.可能是meteor 0.6.1的问题,或者我不小心在代码的某个地方解决了这个问题.
After some time, I tested again the above code with meteor 0.6.4 and it worked without problem. Probably was an issue with meteor 0.6.1 or I accidentally solved the problem somewhere in the code.
这篇关于如何在meteor上创建默认用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文