Hi. How can I check that email is not registered If app uses multi-tenancy? _userManager.FindByEmail(loginModel.EmailAddress) return null if user has tenantId =2. It's need if user forgot his password. Thanks
4 Answer(s)
-
0
If user not logged in, then system works in host mode for IMayHaveTenant filter. So, when you searcy by email, it tries to find from host userts, not the tenant 2.
There are 2 solutions:
- If you know TenantId/TenancyName somehow, then you can set tenantId filter parameter before using FindByEmail as shown below:
CurrentUnitOfWork.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, 42);
- if you don't know tenantId then disable IMayHaveTenant filter (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Filters#DocDisableFilters">http://www.aspnetboilerplate.com/Pages/ ... bleFilters</a>) and use UserManager.Users.Where(...)... to find user by email. But, in this case you can find more than one user with same email in different tenants.
If you really want email uniqueness system-wide, you can write some custom code before user registration (or override UserManager.CreateUserAsync and check it).
-
0
@hikalkan i hav put filter its giving me error "Object reference not set to an instance of an object."
-
0
Hi,
Where did you use this code ? I think it's in a non unitOfWork method and because of that CurrentUnitOfWork is null in your case.
-
0
<cite>ismcagdas: </cite> Hi,
Where did you use this code ? I think it's in a non unitOfWork method and because of that CurrentUnitOfWork is null in your case.
fixed...thanks alot