0
maharatha created
When I am tryinhg to add an user in a tenant then I am trying to search this user in host using the email address or user name and if I get a hit I would like to link these two users automatically while creating the user in Tenant
Can you please guide where should I make this change in CreateUserAsync ?
2 Answer(s)
-
0
hi @maharatha
Try
//link host user if (AbpSession.MultiTenancySide == MultiTenancySides.Tenant) { using (CurrentUnitOfWork.SetTenantId(null)) { _userAccountRepository.Insert(new UserAccount { TenantId = user.TenantId, UserName = user.UserName, UserId = user.Id, EmailAddress = user.EmailAddress }); await CurrentUnitOfWork.SaveChangesAsync(); var hostUser = await UserManager.FindByNameAsync(user.UserName) ?? await UserManager.FindByEmailAsync(user.EmailAddress); if (hostUser != null) { await _userLinkManager.Link(user, hostUser); } } }
-
0
Thank You it worked.