Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

UserManager for different UserTypes #1883


User avatar
0
eggersa created

Hello.

I have to introduce a second type of user. To do that I simply inherit from the User class und put all the type related properties in the specific subclass (using Table per Type Hierarchy) like so:

public abstract class User : AbpUser<Tenant, User>
{
	// ...
}

// example of a concrete user type
[Table("ApplicationUsers")]
public class ApplicationUser : User
{
	// ...
}

However, it does not seem possible using ASP .NET Zero based on Boilerplate 0.8.4 to have a specific UserManager for each user type as the Tenant class uses the abtract User class. And by the restrictions of the AbpUserManager, this does not allow me to combine ApplicationUser with the Tenant:

public abstract class AbpUserManager<TTenant, TRole, TUser> : UserManager<TUser, long>, IDomainService, ITransientDependency
        where TTenant : AbpTenant<TTenant, TUser>
        where TRole : AbpRole<TTenant, TUser>, new()
        where TUser : AbpUser<TTenant, TUser>
{
	// ...
}
// does not work
public class UserManager : AbpUserManager<Tenant, Role, ApplicationUser>
{
	// ...
}

Maybe there is a better solution to have different user types? Reimplementing the whole AbpUserManager does not seem appropriate.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You are right, this is not a good way. You can use current UserManager, add custom methods to it and cast to ApplicationUser when necessary. Current UserManager's methods should also work for your ApplicationUser.

    Or you can upgrade to latest ABP and ABP Zero.