From 6fadc3e1400088e6288cbdb0181c3a9a89c61c41 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Wed, 2 Dec 2020 14:24:47 +0100 Subject: [PATCH] Make "invalid password" error message clearer (#43853) --- .../components/config/auth_provider_homeassistant.py | 4 +++- tests/components/config/test_auth_provider_homeassistant.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/config/auth_provider_homeassistant.py b/homeassistant/components/config/auth_provider_homeassistant.py index 44ac6f23e2d..a8421c4c0f6 100644 --- a/homeassistant/components/config/auth_provider_homeassistant.py +++ b/homeassistant/components/config/auth_provider_homeassistant.py @@ -124,7 +124,9 @@ async def websocket_change_password(hass, connection, msg): try: await provider.async_validate_login(username, msg["current_password"]) except auth_ha.InvalidAuth: - connection.send_error(msg["id"], "invalid_password", "Invalid password") + connection.send_error( + msg["id"], "invalid_current_password", "Invalid current password" + ) return await provider.async_change_password(username, msg["new_password"]) diff --git a/tests/components/config/test_auth_provider_homeassistant.py b/tests/components/config/test_auth_provider_homeassistant.py index 19568ff450b..6af3e6507d5 100644 --- a/tests/components/config/test_auth_provider_homeassistant.py +++ b/tests/components/config/test_auth_provider_homeassistant.py @@ -290,7 +290,7 @@ async def test_change_password_wrong_pw( result = await client.receive_json() assert not result["success"], result - assert result["error"]["code"] == "invalid_password" + assert result["error"]["code"] == "invalid_current_password" with pytest.raises(prov_ha.InvalidAuth): await auth_provider.async_validate_login("test-user", "new-pass")