Finbuckle / Finbuckle.MultiTenant

Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://www.finbuckle.com/multitenant
Apache License 2.0
1.3k stars 265 forks source link

Question about Usermanager.CreateAsync #200

Closed stardocs-services closed 4 years ago

stardocs-services commented 4 years ago

This isn't an issue but more like a question.

I'm learning how to use Finbuckle and was curious as to how you managed to get Usermanager.CreateAsync to allow duplicate usernames? I understand that your tenantId is different but in a normal scenario. Wouldn't Usermanager.CreateAsync return a duplicate username error?

AndrewTriesToCode commented 4 years ago

hi @stardocs-services sorry for the late reply! it works because internally CreateAsync calls UserStore.GetUserByUsername (or something very similar can't recall off the top of my head) which queries EFCore by username to see if one already exists. However the Finbuckle.MultiTenant global query filter is applied so it basically adds an extra where tenantId = __current_tenant__ to that query so if it only returns one for that same query. Does that make sense?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.