admin 管理员组文章数量: 1086019
How can I add users to my app outside of the deployed app itself? I don't want to allow users the ability to create accounts inside the app. Can I create some usernames and passwords from the mand line and then give those to a few users to test the application?
Let me know if you need more information or if I am being unclear. Thank you very much for your time.
How can I add users to my app outside of the deployed app itself? I don't want to allow users the ability to create accounts inside the app. Can I create some usernames and passwords from the mand line and then give those to a few users to test the application?
Let me know if you need more information or if I am being unclear. Thank you very much for your time.
Share Improve this question asked May 28, 2015 at 20:31 user95227user95227 1,9633 gold badges22 silver badges39 bronze badges2 Answers
Reset to default 8Granted that you have theaccounts-password
package installed. (You probably do since you already have login set up.)
You can launch meteor shell
and enter
Accounts.createUser({username: 'john', password: '12345'})
This will take care of all the bcrypting for you. You should also be able to script this.
The relevant documentation with more option parameters is here.
You can add users from the mand prompt but its not that easy.
Essentially you need to run something like this from mongo. For the sake of simplicity I'm not going to add in bcrypt code to make passwords.
Instead you can use a generic meteor password (default). For this create a meteor app, add in accounts-password
and create a user account. Use the services.password.bcrypt
value for all users). When you create a user account this bcrypt has represents the created user's password.
Then you can create a default script:
var user = {
"createdAt": new Date(),
"emails": [ ],
"username": "<username>",
"profile": {
"name": "<Name>"
},
"services": {
"password": {
"bcrypt": "$2a$10$eUVSifclpbABCDEFGHIJKLmnopqr12323112ABBBCEDOINg2A7q0e"
},
"resume": {
"loginTokens": [ ]
}
}
}
db.users.add(user);
Then you can run this script (be sure to replace the and values. Also the _id if you can with a random string. This way mongodb will generate the _id as an ObjectID
.
Then you can run this script (if you called it myjsfile.js) from the mand prompt (if mongo is on the local port 3001):
mongo localhost:3001/meteor myjsfile.js
本文标签: javascriptMeteorJS how to add users from command promptStack Overflow
版权声明:本文标题:javascript - MeteorJS how to add users from command prompt - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744032731a2521804.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论