meteor的restrictCreationByEmailDomain选项如何工作?

lin*_*ran 6 javascript node.js meteor meteorite

我只是阅读meteor的帐户配置选项,"restrictCreationByEmailDomain"选项很棒

Accounts.config({ restrictCreationByEmailDomain: 'school.edu' })
Run Code Online (Sandbox Code Playgroud)

我想知道我可以使用逗号或数组分隔的域列表代替'school.edu'是否有任何简单的流星帐户系统教程?请帮助

Sub*_*bio 8

restrictCreationByEmailDomain字符串或函数

如果设置,则仅允许在指定域中具有电子邮件的新用户或谓词函数返回true.使用基于密码的登录和公开电子邮件地址的外部服务(Google,Facebook,GitHub).

Accounts.config({
  restrictCreationByEmailDomain: function(email) {
    var domain = email.slice(email.lastIndexOf("@")+1); // or regex
    var allowed = ["school.edu", "school.edu.br"];
    return _.contains(allowed, domain);
  },
  ...
});
Run Code Online (Sandbox Code Playgroud)