Multi tenant app

0
I'm trying to make a muti tenant app without using the Multi tenant administration from the Marketplace. It should also work without that (is what I understood).   The goal is that the currentuser (is employee of a company) only see the clients belonging to that company. So I have an entity Bedrijf (Company), an entity Klant (Client), an entity Medewerker (employee). Employee is = generalisation Amdministration account Association Medewerker – Bedrijf = * – 1 Association Klant – Bedrijf = * – 1 If I read the mendix documentation I need to make a Xpath contraint in the entity Klant, with Path to user. That gives the following result.     But that doesn't work. With this Xpath constraint, the currentuser is able to create and save a new Klant, but doens't see the new Klant. If I remove the Xpath constraint, then the currentuser is able to see the Klant created while the Xpath constraint wasn't removed.   I read a lot of other qustions about this issue, but it didn't solve my problem.  
asked
1 answers
0

Indeed multitenancy can be done without this module but it could help you understand multitenancy.
You first mistake is that an employee has an account not is an account. Make a one on one reference between account and Medewerker(employee) and do not inherit.

Now your Klant (client) object is your tenant object. This means that every entity you create needs a reference to that tenant object. Use after create actions to always attach the right Klant to each and every object.

You can then use this reference in your access rules where you check that a user can only read entities that have a reference to the same Klant(Client) as that user.

Regards,

Ronald

 

answered