Verify cloud user exists during boot (#25119)

This commit is contained in:
Paulus Schoutsen committed 2019-07-15 13:57:28 -07:00
1 parent 8996e330b8
commit 65593e36b1
2 files changed
+37 -1

No files matched your search

+7 -1
View File
@@ -157,7 +157,13 @@ async def async_setup(hass, config):
await prefs.async_initialize()
# Cloud user
if not prefs.cloud_user:
user = None
if prefs.cloud_user:
# Fetch the user. It can happen that the user no longer exists if
# an image was restored without restoring the cloud prefs.
user = await hass.auth.async_get_user(prefs.cloud_user)
if user is None:
user = await hass.auth.async_create_system_user(
'Home Assistant Cloud', [GROUP_ID_ADMIN])
await prefs.async_update(cloud_user=user.id)