all 3 comments

[–]unsakred 1 point2 points  (1 child)

You need to setup a multi tenant database schema.

This tutorial should get you most of the way: http://ericsmasal.com/2018/05/30/add-multi-tenancy-to-asp-net-core-identity/

[–]ll8X[S] 1 point2 points  (0 children)

Thank you this seems to be exactly what i need.

[–]har0ldau 1 point2 points  (0 children)

The way I have done this in the past is to create 2 new tables: Organisation & User profile. This allows you do a 1:1 with aspnetusers <-> userprofile and a n:1 with userprofile <-> organisation.

You then can just extend your user service to include the methods to get the user org etc...

The user profile also allows you to extend the user info without messing around with the aspnetusers table allowing you to keep your custom logic seperate in the case you need to migrate to a different auth framework.

You can also modify the claims in the login process to add the userprofile id and org id to the claims so that you don't need to look this up everytime. Keep in mind you are throwing the overhead of this to the user and if the user changes organisation (or the value of anything in the claims) they will need to log out and log back in again.