Accounts.registerLoginHandler与流星密码 [英] Accounts.registerLoginHandler with passwords in Meteor
问题描述
我是新来的流星和我被困在注册登录处理,让我用密码来认证用户。
I'm new to meteor and am stuck on registering a login handler that lets me use the password to authenticate the user.
我是从 http://meteorhacks.com 工作关闭code一>
在服务器端code是如下:
The server side code is as follows:
Accounts.registerLoginHandler(function(loginRequest) {
var userId = null;
var user = Meteor.users.findOne({'emails.address': loginRequest.email, password: loginRequest.password, 'proile.type': loginRequest.type});
if(user) {
userId = user._id;
}
return { id: userId}
如果我拿出密码字段,只使用电子邮件和类型的人也能正常工作。我如何获得这与密码的工作呢?
This works fine if I take out the password field and just use the email and type ones. How do I get this working with the password as well?
推荐答案
底线,你不能直接通过明文密码进行搜索。您需要验证通过SRP口令这是一个有点棘手,因为没有它的任何文件。幸运的是,流星是开源的!良好的开端是在帐号密码
:https://github.com/meteor/meteor/blob/master/packages/accounts-password/password_server.js
Bottom line, you can't directly search via the plaintext password. You need to verify the password via SRP which is a little tricky as there isn't any documentation on it. Luckily Meteor is open source! A good start is at the accounts-password
: https://github.com/meteor/meteor/blob/master/packages/accounts-password/password_server.js
有已经是一个包,可以为你(就是上面的文件是)做密码登录。您可以通过将其添加到您的项目流星添加帐户密码
。
There already is a package that can do password logins for you (the one the above file is from). You can add it to your project via meteor add accounts-password
.
然后,你可以与登录 Meteor.loginWithPassword
Then you could login with Meteor.loginWithPassword
这篇关于Accounts.registerLoginHandler与流星密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!