Skip to content

Commit 8505e32

Browse files
authored
Add dept validation to user updates (#906)
1 parent 91297d1 commit 8505e32

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

backend/app/admin/service/user_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ async def update(*, db: AsyncSession, pk: int, obj: UpdateUserParam) -> int:
108108
raise errors.NotFoundError(msg='用户不存在')
109109
if obj.username != user.username and await user_dao.get_by_username(db, obj.username):
110110
raise errors.ConflictError(msg='用户名已注册')
111+
if obj.dept_id and obj.dept_id != user.dept_id and not await dept_dao.get(db, dept_id=obj.dept_id):
112+
raise errors.NotFoundError(msg='部门不存在')
111113
for role_id in obj.roles:
112114
if not await role_dao.get(db, role_id):
113115
raise errors.NotFoundError(msg='角色不存在')

0 commit comments

Comments
 (0)