admins cant be set as curator on backend (#3194)

* set-curator

* updated error
This commit is contained in:
hagen-danswer 2024-11-21 15:33:29 -08:00 committed by GitHub
parent 3c54ae9de9
commit 9a492ceb6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -411,6 +411,8 @@ def _validate_curator_status__no_commit(
.all()
)
# if the user is a curator in any of their groups, set their role to CURATOR
# otherwise, set their role to BASIC
if curator_relationships:
user.role = UserRole.CURATOR
elif user.role == UserRole.CURATOR:
@ -436,6 +438,15 @@ def update_user_curator_relationship(
user = fetch_user_by_id(db_session, set_curator_request.user_id)
if not user:
raise ValueError(f"User with id '{set_curator_request.user_id}' not found")
if user.role == UserRole.ADMIN:
raise ValueError(
f"User '{user.email}' is an admin and therefore has all permissions "
"of a curator. If you'd like this user to only have curator permissions, "
"you must update their role to BASIC then assign them to be CURATOR in the "
"appropriate groups."
)
requested_user_groups = fetch_user_groups_for_user(
db_session=db_session,
user_id=set_curator_request.user_id,