Fix: Add / Update user error when a role was added.

This commit is contained in:
Amritanshu Agrawal 2021-09-16 12:21:42 +05:30
parent 176559466a
commit f2d617bbce
3 changed files with 5 additions and 1 deletions

View File

@ -102,7 +102,7 @@ def add_roles(user: User, roles: List[schemas.RoleItem], db: Session) -> None:
ug = [g for g in user.roles if g.id == role.id_]
ug = None if len(ug) == 0 else ug[0]
if role.enabled and ug is None:
user.roles.append(db.execute(select(Role).where(Role.id == role.id_)).one())
user.roles.append(db.execute(select(Role).where(Role.id == role.id_)).scalar_one())
elif not role.enabled and ug:
user.roles.remove(ug)

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
cd "$parent_path" || exit

View File

@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
cd "$parent_path" || exit