Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong group creation in mutate UserCreation #1762

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/ai/backend/manager/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sqlalchemy as sa
from dateutil.parser import parse as dtparse
from graphene.types.datetime import DateTime as GQLDateTime
from graphql import Undefined
from passlib.hash import bcrypt
from sqlalchemy.dialects import postgresql as pgsql
from sqlalchemy.engine.result import Result
Expand Down Expand Up @@ -574,6 +575,8 @@ async def mutate(
_status = UserStatus.ACTIVE if props.is_active else UserStatus.INACTIVE
else:
_status = UserStatus(props.status)
group_ids = [] if props.group_ids is Undefined else props.group_ids

user_data = {
"username": username,
"email": email,
Expand Down Expand Up @@ -616,11 +619,11 @@ async def _post_func(conn: SAConnection, result: Result) -> Row:
user=created_user.uuid,
)
await conn.execute(kp_insert_query)
model_store_query = sa.select([groups.c.uuid]).where(
model_store_query = sa.select([groups.c.id]).where(
groups.c.type == ProjectType.MODEL_STORE
)
model_store_gid = (await conn.execute(model_store_query)).first()["uuid"]
gids_to_join = props.group_ids + [model_store_gid]
model_store_gid = (await conn.execute(model_store_query)).first()["id"]
gids_to_join = [*group_ids, model_store_gid]

# Add user to groups if group_ids parameter is provided.
if gids_to_join:
Expand Down
Loading