Meteor User Account Settings email validation

I am using Meteor user accounts api to create user accounts.

https://github.com/meteor-useraccounts/core/blob/master/Guide.md

Now, I wanted to add email restriction to particular domain such as only @mydomain.org so that only those users with the domain will be allowed to log into the system while other users with other domains such as gmail.com would not be able to log into the system.

Please provide your suggestions to implement the above.

The restriction code must run on server side.

import { Accounts } from 'meteor/accounts-base';

Meteor.startup(function() {
  Accounts.validateNewUser((user) => {
    // do some validation here.
    // throw some error
    // or return true
  });
});

import this to server side code, works great to me
Robin

Accounts.config({

restrictCreationByEmailDomain:'mydomain.com'

});

The restrictCreationByEmailDomain is the solution if you want to completely block people not from your domain signing up. You said login not sign-up so you might be asking about something more than that.

If you want to do something fancier where you have two classes of accounts still letting the others sign up. So allow those from all email domains, then you would need to do something in the onCreateUser hook to set a flag on the account.