Skip to content

Commit

Permalink
fix: wrong group creation in mutate UserCreation (#1762)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa authored Dec 7, 2023
1 parent a4f62f9 commit 902c9f0
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit 902c9f0

Please sign in to comment.