makefile 1.1 and permissions 1.0

This commit is contained in:
2025-10-05 02:09:28 +03:00
parent 46c6e1cd94
commit 6db14b2329
6 changed files with 119 additions and 15 deletions

View File

@@ -63,6 +63,7 @@ async def delete_user(email:str,current_user: str = Depends(JWT.current_user)):
@api.put("/user_update/{email}", response_model=pydentic.UserOut)
async def update_user(email:str, updated_row: pydentic.UserUpdate, current_user: str = Depends(JWT.current_user)):
user = await db.get_user_by_email(email)
perm = user.permissions[0]
if not user:
raise HTTPException(status_code=401, detail="The user isn't found")
changed = False
@@ -78,8 +79,14 @@ async def update_user(email:str, updated_row: pydentic.UserUpdate, current_user:
if updated_row.password is not None and updated_row.password != user.password:
user.password = updated_row.password
changed = True
if updated_row.can_edit is not None and updated_row.can_edit != perm.can_edit:
perm.can_edit = updated_row.can_edit
changed = True
if updated_row.can_delete is not None and updated_row.can_delete != perm.can_delete:
perm.can_delete = updated_row.can_delete
changed = True
if changed:
await db.update_user(user)
user = await db.update_user(user_info=user, perm_info=perm)
else:
pass
return user