Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!