Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Multiple User types and Identity

In my project, I am currently working on user roles (claims) and registration.

I am struggling with which approach I should use or if there is any source I can base on. I have two types of application users (related to the app's domain), let's say they are Lecturer and Student, these entities differ by a few fields so I wanted to have them separated.

How should I design the entities now?

There are a few cases but I'm not sure how to cover them.

User can be Lecturer

User can be Student

User can be both Lecturer and Student (at the same time)

How do I manage that?

I was thinking about adding a foreign key to each entity (Lecturer/Student/AnyOtherType) to reference IdentityUser and during the registration define the type of user by claims

userIdentity.AddClaim(new Claim(ClaimTypes.Role, "Lecturer"))
userIdentity.AddClaim(new Claim(ClaimTypes.Role, "Student"));

Do you think it is a good idea? How to handle incoming requests based on user role? I know I can use something similar to the following example in some Services, but ideally, I would like to avoid unnecessary calls to the DB just to filter out the needed data in the Service

user.IsInRole("lecturer")

I'm focusing on DDD rn.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda