Looking for Scoped logins in meteor (e.g. Like Slack)

Hey. I am writing an application in our comany based upon meteor. Now, we decided that we want to allow our customers to register own subdomains/domains and let their customers log in on these. Just like slack.

The problem is that we sell whitelabel solutions, so it must look for each domain as it was an own running application with an own database.

Is there any way to “scope” accounts-base?

The goal is to add a field to the user like “hostname” and check if the user has the right hostname AND the right E-Mail/Facebook/Google Token.

I found that I can get the hostname that was requested with the connection of each ddp call (methods and publications) (Checking for the right scope inside of Meteor.onConnection) but inside of Accounts.onCreateUser there is no this.connection that would give me the ddp session id or the hostname, also I don’t know how to allow that an email address is used multiple times.

I think you are looking for mizzao:partitioner

https://atmospherejs.com/mizzao/partitioner

And if you don’t want a blackbox solution you can read the ideas from that package or its source to come up with your own solution.

Basically it is all about intercepting the calls to the collection and diverting them and it uses collection-hooks under the hood.

1 Like

I found out that with the help of Method Hooks this is possible.

I Hooked the method “login” and “createUser” (and might need to hook more methods - but as a proof of concept it works):
With theese hooks, we have an own user system for each domain, the app is called at:

Meteor.beforeMethods ['createUser'], (params) ->
	params.email = params.email + "@@"  + @connection.httpHeaders.host
	return params

Meteor.beforeMethods ['login'], (params) ->
	params.email = params.email + "@@" +@connection.httpHeaders.host
	return params

What I still need to do:

  • Modify the readout process of email addresses as they are now in the format user@owndomain@@hostdomain
1 Like