Meteor - 获取尝试登录的电子邮件地址
Meteor - get email address of attempted login
我需要获取用户在尝试登录失败时使用的电子邮件地址,以检查他们是否在应用程序外部注册。
这是我的代码;
Accounts.validateLoginAttempt(function(info){
if (!info.allowed)
{
console.log("we don't have that user " + info.user.emails[0]['address']);
return false;
} else {
var user = info.user;
console.log("created " + user.createdAt);
console.log("emails is " + user.emails[0]['address']);
return true;
}
});
如果不允许登录,我会得到这个 Cannot read property 'emails' of undefined
因为显然该用户不在用户集合中。我的问题是,是否可以通过某种方式查看尝试登录的电子邮件和密码?
试试这个:
Accounts.validateLoginAttempt(function(info) {
console.log("user");
console.dir(info.methodArguments[0].user);
console.log("password");
console.dir(info.methodArguments[0].password);
});
编辑:另外,我写了一个 Meteor 包来解决这个问题,可在 https://atmospherejs.com/chipcastledotcom/accounts-email.
的 Atmosphere 上找到
我需要获取用户在尝试登录失败时使用的电子邮件地址,以检查他们是否在应用程序外部注册。
这是我的代码;
Accounts.validateLoginAttempt(function(info){
if (!info.allowed)
{
console.log("we don't have that user " + info.user.emails[0]['address']);
return false;
} else {
var user = info.user;
console.log("created " + user.createdAt);
console.log("emails is " + user.emails[0]['address']);
return true;
}
});
如果不允许登录,我会得到这个 Cannot read property 'emails' of undefined
因为显然该用户不在用户集合中。我的问题是,是否可以通过某种方式查看尝试登录的电子邮件和密码?
试试这个:
Accounts.validateLoginAttempt(function(info) {
console.log("user");
console.dir(info.methodArguments[0].user);
console.log("password");
console.dir(info.methodArguments[0].password);
});
编辑:另外,我写了一个 Meteor 包来解决这个问题,可在 https://atmospherejs.com/chipcastledotcom/accounts-email.
的 Atmosphere 上找到