Fix update person validation (#30691)
parent
dc57d670d8
commit
3715f821d7
|
@ -214,7 +214,7 @@ class PersonStorageCollection(collection.StorageCollection):
|
||||||
|
|
||||||
user_id = update_data.get(CONF_USER_ID)
|
user_id = update_data.get(CONF_USER_ID)
|
||||||
|
|
||||||
if user_id is not None:
|
if user_id is not None and user_id != data.get(CONF_USER_ID):
|
||||||
await self._validate_user_id(user_id)
|
await self._validate_user_id(user_id)
|
||||||
|
|
||||||
return {**data, **update_data}
|
return {**data, **update_data}
|
||||||
|
|
|
@ -514,6 +514,18 @@ async def test_ws_update(hass, hass_ws_client, storage_setup):
|
||||||
"id": 6,
|
"id": 6,
|
||||||
"type": "person/update",
|
"type": "person/update",
|
||||||
"person_id": persons[0]["id"],
|
"person_id": persons[0]["id"],
|
||||||
|
"user_id": persons[0]["user_id"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
resp = await client.receive_json()
|
||||||
|
|
||||||
|
assert resp["success"]
|
||||||
|
|
||||||
|
resp = await client.send_json(
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"type": "person/update",
|
||||||
|
"person_id": persons[0]["id"],
|
||||||
"name": "Updated Name",
|
"name": "Updated Name",
|
||||||
"device_trackers": [DEVICE_TRACKER_2],
|
"device_trackers": [DEVICE_TRACKER_2],
|
||||||
"user_id": None,
|
"user_id": None,
|
||||||
|
|
Loading…
Reference in New Issue