这是通过电子邮件登录的简单解决方案,它在用户创建后停用自动登录并拒绝以后登录,直到验证电子邮件地址:
if (Meteor.isServer) {
Accounts.validateLoginAttempt(function(attemptInfo) {
if (attemptInfo.type == 'resume') return true;
if (attemptInfo.methodName == 'createUser') return false;
if (attemptInfo.methodName == 'login' && attemptInfo.allowed) {
var verified = false;
var email = attemptInfo.methodArguments[0].user.email;
attemptInfo.user.emails.forEach(function(value, index) {
if (email == value.address && value.verified) verified = true;
});
if (!verified) throw new Meteor.Error(403, 'Verify Email first!');
}
return true;
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2466 次 |
| 最近记录: |