I have an admin system, the customer can select a tenant from a drop down box and website redirects to the tenant home page. The customer can continue to maintain the tenant data.
The problem I could have is if a customer opens tenant A in tab 1, then in tab 2 opens tenant B. If they go back to tab 1 and save a customer record for example it will try to save the record against tenant b.
I use a scoped tenant class with a connection string in it, middleware on each request checks a cookie for the tenant id and places the tenant connection string in the scoped class. The scoped class is used by the repositories to retrieve the correct tenant data.
So in the example above tab 2 will change the cookie tenant id, the middleware will change the scoped connection string and when tab 1 saves its using tenant B connection string.
I have a nasty JavaScript hack that keeps track of open admin tabs and closes and warns the user. It's a nasty hack, causing more issues that it's worth.
Anyone any ideas, oh and I really want to avoid having the tenant id in the query string. I'm thinking of something earlier in the life cycle of the page to catch the change and in this case redirect the request to the home page for the tenant.
I know it's a long shot, but any ideas? Stackoverflow has failed me. Thanks in advance.
The problem I could have is if a customer opens tenant A in tab 1, then in tab 2 opens tenant B. If they go back to tab 1 and save a customer record for example it will try to save the record against tenant b.
I use a scoped tenant class with a connection string in it, middleware on each request checks a cookie for the tenant id and places the tenant connection string in the scoped class. The scoped class is used by the repositories to retrieve the correct tenant data.
So in the example above tab 2 will change the cookie tenant id, the middleware will change the scoped connection string and when tab 1 saves its using tenant B connection string.
I have a nasty JavaScript hack that keeps track of open admin tabs and closes and warns the user. It's a nasty hack, causing more issues that it's worth.
Anyone any ideas, oh and I really want to avoid having the tenant id in the query string. I'm thinking of something earlier in the life cycle of the page to catch the change and in this case redirect the request to the home page for the tenant.
I know it's a long shot, but any ideas? Stackoverflow has failed me. Thanks in advance.
Comment