- ABP Framework version: v4.2
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): yes / no
- Exception message and stack trace:
- Steps to reproduce the issue:
We have a scenario where user1 and user2 have same usernames and same emailId . user1 username : ABC Password : 1q2w3E* email : abc@gmail.com TenantId : 1
user2 username : ABC Password : 1q2w3E* email : abc@gmail.com TenantId : 2
We want to implement in such a way that when user1 logs in to Tenant1 he can directly click on Tenant2 and login automatically through code and switch the context of Tenant1 to Tenant2. In the same way user can also switch back to Tenant1 .
We know about ICurrentTenant interface, but want to completely switch the tenants.
https://docs.abp.io/en/abp/latest/Multi-Tenancy#change-the-current-tenant
Is this possible in Abp.io ? If yes, please share the steps to achieving it..
This is high priority for the customer
Thanks
3 Answer(s)
-
0
hi
This only works for MVC with no tiered project.
var isPersistent = (await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme))?.Properties?.IsPersistent ?? false; await SignInManager.SignOutAsync(); using (CurrentTenant.Change(user2.TenantId)) { var user2 = await UserManager.GetByIdAsync(user2.Id.Value); await SignInManager.SignInAsync(user2, isPersistent); }
-
0
Ok. We will soon try this approach and update you.
Thanks !
-
0
Hello @maliming ,
Thanks a million ! This worked and solved a big hurdle for us !!