This commit is contained in:
2025-10-12 15:00:23 +03:00
parent a2aadc82b7
commit a4f9af3e2d
8 changed files with 59 additions and 17 deletions

View File

@@ -87,19 +87,19 @@ async def update_user(email:str, updated_row: pydentic.UserUpdate, current_user:
changed = True
# пароль
if updated_row.password:
if not verify_password(updated_row.password, user.password):
if not db.verify_password(updated_row.password, user.password):
user.password = updated_row.password
changed = True
# права (только для админа)
if current_perms.is_admin:
perm_fields = ["can_edit", "can_delete", "can_view", "is_admin"]
perm_fields = ["can_edit", "can_delete", "can_view"]
for field in perm_fields:
new_value = getattr(updated_row, field)
if new_value is not None and new_value != getattr(perm, field):
setattr(perm, field, new_value)
changed = True
if changed:
user = await db.update_user(user_info=user, perm_info=perm)
user = await db.update_user(email = email, user_info=user, perm_info=perm)
return user
@api.post("/login")
async def login_user(form_data: OAuth2PasswordRequestForm = Depends()):