Import onboarding (#64115)

* Add type hints to onboarding

* Import onboarding

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/64121/head
epenet 2022-01-14 16:29:48 +01:00 committed by GitHub
parent 532c3aca33
commit 9f61aecd5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -75,6 +75,7 @@ import voluptuous_serialize
from homeassistant import data_entry_flow
from homeassistant.auth.models import Credentials
from homeassistant.components import onboarding
from homeassistant.components.http.auth import async_user_not_allowed_do_auth
from homeassistant.components.http.ban import (
log_invalid_auth,
@ -105,7 +106,7 @@ class AuthProvidersView(HomeAssistantView):
async def get(self, request):
"""Get available auth providers."""
hass = request.app["hass"]
if not hass.components.onboarding.async_is_user_onboarded():
if not onboarding.async_is_user_onboarded(hass):
return self.json_message(
message="Onboarding not finished",
status_code=HTTPStatus.BAD_REQUEST,

View File

@ -15,7 +15,7 @@ import jinja2
import voluptuous as vol
from yarl import URL
from homeassistant.components import websocket_api
from homeassistant.components import onboarding, websocket_api
from homeassistant.components.http.view import HomeAssistantView
from homeassistant.components.websocket_api.connection import ActiveConnection
from homeassistant.config import async_hass_config_yaml
@ -583,7 +583,7 @@ class IndexView(web_urldispatcher.AbstractResource):
"""Serve the index page for panel pages."""
hass = request.app["hass"]
if not hass.components.onboarding.async_is_onboarded():
if not onboarding.async_is_onboarded(hass):
return web.Response(status=302, headers={"location": "/onboarding.html"})
template = self._template_cache or await hass.async_add_executor_job(

View File

@ -35,7 +35,7 @@ class OnboadingStorage(Store):
@bind_hass
@callback
def async_is_onboarded(hass):
def async_is_onboarded(hass: HomeAssistant) -> bool:
"""Return if Home Assistant has been onboarded."""
data = hass.data.get(DOMAIN)
return data is None or data is True
@ -43,7 +43,7 @@ def async_is_onboarded(hass):
@bind_hass
@callback
def async_is_user_onboarded(hass):
def async_is_user_onboarded(hass: HomeAssistant) -> bool:
"""Return if a user has been created as part of onboarding."""
return async_is_onboarded(hass) or STEP_USER in hass.data[DOMAIN]["done"]