0
mrvithan created
I try to create a new user with no Tenant in an AppService using this code :
//Create user
var user = new User
{
Name = input.Name.Trim(),
Surname = input.Name.Trim(),
EmailAddress = input.Email.Trim(),
IsActive = true,
TenantId = 1
};
user.UserName = input.Code;
user.Password = new PasswordHasher().HashPassword(input.Password);
user.Roles = new List<UserRole>();
foreach (var agentRole in _roleManager.Roles.Where(r => r.Name == StaticRoleNames.Host.Agent).ToList())
{
user.Roles.Add(new UserRole { RoleId = agentRole.Id });
}
_userManager.Create(user);
I also setup a new role called 'Agent' with Tenant = 1. There is no error but the user has not been created.
Any suggestion ?