Created a new system for RBAC. Essentially, individuals can now use a toggle at the top of the registration page to log in as either a teacher or student, which assigns the role of either "User" or "Teacher." Upon login, the system now uses an email query to verify whether the user is a teacher or student, and proceeds accordingly.
Changes Made:
Added radio switch at the top of register.html page: can be on either the student or teacher position, but not both at once.
Added relevant css styling for the role-switch in register.css.
Updated relevant register.js code to add event listeners for the new role switch.
Updated relevant register.js code to be able to retain position of switch upon failed attempt/redirect.
Updated register.js code so that when in 'teacher' position, the grade field disappears and input for it is no longer needed for form submission.
Updated register route in auth.py so the system now requests the role attribute, and based on "teacher" or "student" assigns a new User or Teacher model.
Updated login route in auth.py so the system now uses the inputted email to determine whether the user is a teacher or student, and redirects accordingly.
Added temporary teacher redirect page (we will decide what teachers should be able to do later).
Notes/Issues:
IMPORTANT: Under models.py, the Teacher class had yrs_specialization set to Nullable=False. This was causing issues as the registration for teachers does not ask for this field, so it should be nullable in reality. I am not sure of how to migrate the database, so I would appreciate if someone could migrate the database with my new changes or show me how.
IMPORTANT: For some reason, line 68 in auth.py (role = request.form.get("role")) is not functioning as intended. I am completely unsure why this issue exists, but it needs to be fixed for the RBAC system to work and be tested.
Created a new system for RBAC. Essentially, individuals can now use a toggle at the top of the registration page to log in as either a teacher or student, which assigns the role of either "User" or "Teacher." Upon login, the system now uses an email query to verify whether the user is a teacher or student, and proceeds accordingly.
Changes Made:
Notes/Issues: