C
C#13mo ago
Zekz

❔ Setup JwtAuthentication with multiple user table in web api 7

Hello I am new to web development and I need guidance on how to setup jwt authentication and authorization. The first img is my database (it have 3 user table: Student, Teacher, Staff and the staff have the staff role: Admin, Testing Admin, Testing Staff), this database is for a exam schedule management system. The reason why I dont group all 3 of the table into 1 user table is because of the Exam Session table relationship with these 3 table (it have staffId to know the staff that created the session, it have the teacherId to know who protor that session and it link to a ExamEnrollment for a many-many relationship with multiple student). The second img is all I did so far and I need guidance on what to do next.
No description
No description
4 Replies
Bailey
Bailey13mo ago
You can still use this structure. Just add a role to the claims. When decoding or checking, the role can be read and you know who it is. If you look for a way to check if the username and password is in 1 of the tables, I wouldnt do that. Someone should login where he/she is expected
Zekz
ZekzOP13mo ago
I was thinking of only have 1 login screen and based on the login info to know whos the user. Creating 3 different login screen is not really my goal
Bailey
Bailey13mo ago
You can go 2 ways namely: Create a new table which contains offcourse an ID , username, password, role and add the role when registring. You still end up with the same claims system. but then you can use this. the ID is for connecting with other tables. However keep in mind that you do not couple to 2 tables. other option is to just search in all 3 tables for checking like does the username exist. no doubles etc. Just an advice look at microsoft identity which is considered save. maybe ou can learn something from that.
Accord
Accord13mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server