mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 20:25:07 +02:00
Fix credentials lookup (#15409)
This commit is contained in:
@@ -311,10 +311,7 @@ class AuthManager:
|
|||||||
if not credentials.is_new:
|
if not credentials.is_new:
|
||||||
for user in await self._store.async_get_users():
|
for user in await self._store.async_get_users():
|
||||||
for creds in user.credentials:
|
for creds in user.credentials:
|
||||||
if (creds.auth_provider_type ==
|
if creds.id == credentials.id:
|
||||||
credentials.auth_provider_type
|
|
||||||
and creds.auth_provider_id ==
|
|
||||||
credentials.auth_provider_id):
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
raise ValueError('Unable to find the user.')
|
raise ValueError('Unable to find the user.')
|
||||||
|
@@ -94,6 +94,21 @@ async def test_login_as_existing_user(mock_hass):
|
|||||||
}])
|
}])
|
||||||
ensure_auth_manager_loaded(manager)
|
ensure_auth_manager_loaded(manager)
|
||||||
|
|
||||||
|
# Add a fake user that we're not going to log in with
|
||||||
|
user = MockUser(
|
||||||
|
id='mock-user2',
|
||||||
|
is_owner=False,
|
||||||
|
is_active=False,
|
||||||
|
name='Not user',
|
||||||
|
).add_to_auth_manager(manager)
|
||||||
|
user.credentials.append(auth.Credentials(
|
||||||
|
id='mock-id2',
|
||||||
|
auth_provider_type='insecure_example',
|
||||||
|
auth_provider_id=None,
|
||||||
|
data={'username': 'other-user'},
|
||||||
|
is_new=False,
|
||||||
|
))
|
||||||
|
|
||||||
# Add fake user with credentials for example auth provider.
|
# Add fake user with credentials for example auth provider.
|
||||||
user = MockUser(
|
user = MockUser(
|
||||||
id='mock-user',
|
id='mock-user',
|
||||||
|
Reference in New Issue
Block a user