mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-10-09 20:55:06 +02:00
admins cant be set as curator on backend (#3194)
* set-curator * updated error
This commit is contained in:
@@ -411,6 +411,8 @@ def _validate_curator_status__no_commit(
|
|||||||
.all()
|
.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:
|
if curator_relationships:
|
||||||
user.role = UserRole.CURATOR
|
user.role = UserRole.CURATOR
|
||||||
elif 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)
|
user = fetch_user_by_id(db_session, set_curator_request.user_id)
|
||||||
if not user:
|
if not user:
|
||||||
raise ValueError(f"User with id '{set_curator_request.user_id}' not found")
|
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(
|
requested_user_groups = fetch_user_groups_for_user(
|
||||||
db_session=db_session,
|
db_session=db_session,
|
||||||
user_id=set_curator_request.user_id,
|
user_id=set_curator_request.user_id,
|
||||||
|
Reference in New Issue
Block a user