How to use multiple classes as User in Identity - Asp.Net Identity

Asked

Viewed 801 times

3

I want to use 2 classes as User in Identity and could not see this change in code.

Let’s assume that I will use the default class "Applicationuser" that generates an "Aspnetusers" table and I want to use another table "Clients" that inherits from Identity.

The Applicationuser class already inherits from Identity and works fine. I saw that there is a class Applicationusermanager and others that inherit from Applicationuser. Example:

public class ApplicationUser : IdentityUser

public class ApplicationUserManager : UserManager<ApplicationUser>

public class ApplicationSignInManager : SignInManager<ApplicationUser, string>


public class Cliente: IdentityUser

My question is whether I will need to create new classes to inherit from Client, example:

public class ApplicationUserManagerCliente : UserManager<Cliente>
public class ApplicationSignInManagerCliente : SignInManager<Cliente, string>

Would it be that or am I thinking wrong?

  • Why do you have to use 2 classes? Wouldn’t it be better to use only Cliente?

  • It’s because I want to use a user class for access to the administrative area of the site. and another user class for external access. Got it?

  • @Gabrielmoura this is authorization, does not make sense 2 users, create 1 and authorization for the particular area that he can or will not access

1 answer

-1

From what I understand, you want to create two types of users the Conventional User (Userentity) and the System Administrator (Adminuserentity). Userentity will access the normal site and the Administrator will access another site(Adm).

I believe that the ideal would be, create a single user with the default features between the 2 and give them specialized Claims, eg Profile = Admin, Accessosites = Othersite.

See if this link here can help you:https://stackoverflow.com/questions/22855428/how-to-change-table-names-for-asp-net-identity-2-0-with-int-id-columns

has a tutorial that can help you : http://eduardopires.net.br/2014/08/asp-net-identity-tutorial-completo/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.