System groups (#18303)

* Add read only and admin policies

* Migrate to 2 system groups

* Add system groups

* Add system groups admin & read only

* Dont' mutate parameters

* Fix types
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2018-11-08 12:57:00 +01:00
1 parent 54b0cde52a
commit f7f0a4e811
14 files changed
+309 -68

No files matched your search

+3 -3
View File
@@ -13,6 +13,7 @@ from homeassistant.core import callback, HomeAssistant
from homeassistant.util import dt as dt_util
from . import auth_store, models
from .const import GROUP_ID_ADMIN
from .mfa_modules import auth_mfa_module_from_config, MultiFactorAuthModule
from .providers import auth_provider_from_config, AuthProvider, LoginFlow
@@ -133,7 +134,7 @@ class AuthManager:
name=name,
system_generated=True,
is_active=True,
groups=[],
group_ids=[],
)
self.hass.bus.async_fire(EVENT_USER_ADDED, {
@@ -144,11 +145,10 @@ class AuthManager:
async def async_create_user(self, name: str) -> models.User:
"""Create a user."""
group = (await self._store.async_get_groups())[0]
kwargs = {
'name': name,
'is_active': True,
'groups': [group]
'group_ids': [GROUP_ID_ADMIN]
} # type: Dict[str, Any]
if await self._user_should_be_owner():