Adding ability to update / patch by sku, adding uniqueness constraint violation checks
This commit is contained in:
1 parent
af5343da0c
commit
d8db87c13e
13 files changed
+541
-13
No files matched your search
@@ -82,6 +82,12 @@ async def update_user(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="User not found"
|
||||
)
|
||||
changes = payload.model_dump(exclude_unset=True)
|
||||
if "email" in changes:
|
||||
existing = await user_crud.get_by_email(db, changes["email"])
|
||||
if existing is not None and existing.id != target.id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT, detail="Email already registered"
|
||||
)
|
||||
target = await user_crud.update(db, target, changes)
|
||||
await audit_crud.log(
|
||||
db,
|
||||
|
||||
Reference in new issue
Block a user