MultiTenant application using account-base package

I am working on a MutliTenant application and using account-base package to create and manage user accounts.
I have got around the issue of unique userid by concatening the domain with the email. I am however getting an error when registering the same emailid for different domains.
What is the communities recommendation for account registraton and all the functionality that the Accounts-UI, accounts-base package provides?

Our approach was to have a single user registered and then assign roles to the user that correspond to each domain. That way your user can still have per domain permissions but they only exist once in your db.

Thank you @znewsham fir this input.

@znewsham, Register user works fine but how would I login user with username, password, domain as inputs?. Would I login user with Meteor.LoginUserWithPassword and username, password as inputs and store the “logged in domain” in session?

A couple of ways, depends on what you need. You can either call a method to set the domain on the connection, or you can just ensure that with every method and subscription you send the domain as well

Is it possible that the same person would be signed up under different domains?

If not then you have a couple of other options:

  1. Only allow log in by email, not usernames.
  2. Keep the default behavior of unique usernames across all domains - how likely is it that users on different domains will choose the same username? If they try, make them pick another one.

Thanks @wildhart for your input, user getting signed up under different domains is a edge case and we need to code for it.
We plan on only allow login via email and ask user to select a domain if they have registered for multiple domains.

Thank you @znewsham for your input,
I will go with passing domain on every server method call.
Also I don’t understand “set the domain on the connection”? For my knowledge, do you mean storing the domain like userid is stored aka Meteor.UserId()? How would I do that?
Would I use something like on the discussion here:

In a Meteor method, you can access the current connection, then you can set an arbitrary variable on it, which you can then access in other methods/publications, something like this:

  const invocation = DDP._CurrentMethodInvocation.get();
  if (invocation) {
    const session = invocation._session || invocation.connection;
    if (session && {
      session.whatever = whateverIWant;
      if (Meteor.default_server.sessions[]) {
        Meteor.default_server.sessions[].whatever = whateverIWant

I’d advise creating some helper methods, Meteor.setDomain(...) and Meteor.getDomain() for example


Not trying to be negative here, multi tenant application design is kind of old school now.

Package your application with docker and spin new application for each of your clients.

I’ve certainly seen that school of thought as well - but I’d argue the opposite. One “instance” per client poorly utilises selected resources. Particularly if you have separate databases for each client too - in fact you start running into mongo collection limits. And if you have single tenant on the app server, but multi tenant in the DB - your application code still needs to do all the same work.

In general, unless you have very specific security concerns, or compliance concerns. Or, you know that every client needs a dedicated server (pair of servers really, for redundency) then multi tenant is much more cost effective, and far FAR easier to manage