how meteor's restrictCreationByEmailDomain option work?
Asked Answered
V

1

6

i just read meteor's accounts config options, "restrictCreationByEmailDomain" option is awesome

Accounts.config({ restrictCreationByEmailDomain: 'school.edu' })

i want to know can i use a list of domains separated by comma or array in place of 'school.edu' is there any simple tutorial for meteor accounts system ? pls help

Valueless answered 9/11, 2013 at 2:41 Comment(0)
A
9

restrictCreationByEmailDomain String Or Function

If set, only allow new users with an email in the specified domain or if the predicate function returns true. Works with password-based sign-in and external services that expose email addresses (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);
  },
  ...
});
Amelita answered 9/11, 2013 at 4:26 Comment(1)
I don't know why you commented out the domain thing, that's kinda the way it was designed when we added this optionEmbankment

© 2022 - 2024 — McMap. All rights reserved.