You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a PUT endpoint with the routing ('/changeUserRole') that asynchronously calls a function called changeUserRole. The changeUserRole function should find the user by their ID in the database and update their role from STUDENT to TEACHER.
The prisma model looks like:
model User {
id Int @id @default(autoincrement())
email String @unique
password String
role Role @default(STUDENT)
profile Profile?
cohortId Int?
cohort Cohort? @relation(fields: [cohortId], references: [id])
posts Post[]
deliveryLogs DeliveryLog[]
}
The endpoint returns a response of 201 with the JSON-formatted user if the operation is successful and a response of 401 if the operation fails. The function also returns 401 if the logged in user attempting to change another user's role to teacher is not a teacher using validateTeacherRole which returns false if the logged in user is a student and true if the logged in user is a teacher.
Create a PUT endpoint with the routing ('/changeUserRole') that asynchronously calls a function called
changeUserRole
. ThechangeUserRole
function should find the user by their ID in the database and update their role fromSTUDENT
toTEACHER
.The prisma model looks like:
The user API spec model looks like:
The endpoint returns a response of 201 with the JSON-formatted user if the operation is successful and a response of 401 if the operation fails. The function also returns 401 if the logged in user attempting to change another user's role to teacher is not a teacher using
validateTeacherRole
which returns false if the logged in user is a student and true if the logged in user is a teacher.The text was updated successfully, but these errors were encountered: