Import auth, hassio and person in onboarding (#64542)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/61237/head
parent
8b8f750c41
commit
f9cd67675f
|
@ -8,6 +8,7 @@ from aiohttp.web_exceptions import HTTPUnauthorized
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||
from homeassistant.components import auth, hassio, person
|
||||
from homeassistant.components.auth import indieauth
|
||||
from homeassistant.components.http.const import KEY_HASS_REFRESH_TOKEN_ID
|
||||
from homeassistant.components.http.data_validator import RequestDataValidator
|
||||
|
@ -143,9 +144,7 @@ class UserOnboardingView(_BaseOnboardingView):
|
|||
await provider.data.async_save()
|
||||
await hass.auth.async_link_user(user, credentials)
|
||||
if "person" in hass.config.components:
|
||||
await hass.components.person.async_create_person(
|
||||
data["name"], user_id=user.id
|
||||
)
|
||||
await person.async_create_person(hass, data["name"], user_id=user.id)
|
||||
|
||||
# Create default areas using the users supplied language.
|
||||
translations = await hass.helpers.translation.async_get_translations(
|
||||
|
@ -163,9 +162,7 @@ class UserOnboardingView(_BaseOnboardingView):
|
|||
|
||||
# Return authorization code for fetching tokens and connect
|
||||
# during onboarding.
|
||||
auth_code = hass.components.auth.create_auth_code(
|
||||
data["client_id"], credentials
|
||||
)
|
||||
auth_code = auth.create_auth_code(hass, data["client_id"], credentials)
|
||||
return self.json({"auth_code": auth_code})
|
||||
|
||||
|
||||
|
@ -193,8 +190,8 @@ class CoreConfigOnboardingView(_BaseOnboardingView):
|
|||
)
|
||||
|
||||
if (
|
||||
hass.components.hassio.is_hassio()
|
||||
and "raspberrypi" in hass.components.hassio.get_core_info()["machine"]
|
||||
hassio.is_hassio(hass)
|
||||
and "raspberrypi" in hassio.get_core_info(hass)["machine"]
|
||||
):
|
||||
await hass.config_entries.flow.async_init(
|
||||
"rpi_power", context={"source": "onboarding"}
|
||||
|
@ -241,8 +238,8 @@ class IntegrationOnboardingView(_BaseOnboardingView):
|
|||
)
|
||||
|
||||
# Return authorization code so we can redirect user and log them in
|
||||
auth_code = hass.components.auth.create_auth_code(
|
||||
data["client_id"], refresh_token.credential
|
||||
auth_code = auth.create_auth_code(
|
||||
hass, data["client_id"], refresh_token.credential
|
||||
)
|
||||
return self.json({"auth_code": auth_code})
|
||||
|
||||
|
|
Loading…
Reference in New Issue