我有一个表单,用户在连接表单中输入他们的电子邮件地址和密码。这创建了帐户,但我现在想要进一步开发它。流星:创建帐户之前,Meteor.users收集中不存在检查邮件
client.js
Template.joinForm.events({
'submit .form-join': function(e, t) {
e.preventDefault();
var email = t.find('#email').value,
password = t.find('#password').value,
username = Random.id(),
array = [],
profile = {
nameOfArray: array
};
Accounts.createUser({
email: email,
username: username,
password: password,
profile: profile
}, function(error) {
if (error) {
alert(error);
} else {
Router.go('/');
}
});
}
});
之前创建一个用户帐号,你怎么了:
1,检查从joinForm“电子邮件”变量尚不存在的流星。用户收集(在服务器上处理)?
- 如果'email'确实存在,那么拒绝用户创建?
我已经看到了新的功能,并想知道我是否使用它? http://docs.meteor.com/#/full/accounts_validatenewuser
Accounts.validateNewUser(function (user) {
//pseudo if statement code
if (email not exist) {
1. create the user account and then
Accounts.sendVerificationEmail(userId, [email])
} else {
throw new Meteor.Error(403, "email address is already registered");
}
});
感谢您阅读此。
我不清楚是否使用Accounts.createUser或Accounts.onCreateUser和 应该是客户上的代码,其中服务器上。我的目标是安全地建立帐户,因此,在此过程中从控制台拒绝任何其他修改权限。
卡森,你是对的。验证需要在Accounts.onCreateUser中完成。 – meteorBuzz 2015-03-26 18:36:16