UI Improvements (#7)
* Initial version with UI templates * Implement basic screens * Linting & bump to 0.3.0 * Tick off some TODOs
This commit is contained in:
committed by
GitHub
parent
597d9cdf7d
commit
0d61861343
@@ -4,7 +4,7 @@ from homeassistant.components.http import HomeAssistantView
|
||||
from aiohttp import web
|
||||
from ..oidc_client import OIDCClient
|
||||
from ..provider import OpenIDAuthProvider
|
||||
from ..helpers import get_url
|
||||
from ..helpers import get_url, get_view
|
||||
|
||||
PATH = "/auth/oidc/callback"
|
||||
|
||||
@@ -30,21 +30,29 @@ class OIDCCallbackView(HomeAssistantView):
|
||||
state = params.get("state")
|
||||
|
||||
if not (code and state):
|
||||
return web.Response(
|
||||
headers={"content-type": "text/html"},
|
||||
text="<h1>Error</h1><p>Missing code or state parameter</p>",
|
||||
view_html = await get_view(
|
||||
"error",
|
||||
{
|
||||
"error": "Missing code or state parameter.",
|
||||
"link": get_url("/auth/oidc/redirect"),
|
||||
},
|
||||
)
|
||||
return web.Response(text=view_html, content_type="text/html")
|
||||
|
||||
redirect_uri = get_url("/auth/oidc/callback")
|
||||
user_details = await self.oidc_client.async_complete_token_flow(
|
||||
redirect_uri, code, state
|
||||
)
|
||||
if user_details is None:
|
||||
return web.Response(
|
||||
headers={"content-type": "text/html"},
|
||||
text="<h1>Error</h1><p>Failed to get user details, see console.</p>",
|
||||
view_html = await get_view(
|
||||
"error",
|
||||
{
|
||||
"error": "Failed to get user details, "
|
||||
+ "see Home Assistant logs for more information.",
|
||||
"link": get_url("/auth/oidc/redirect"),
|
||||
},
|
||||
)
|
||||
return web.Response(text=view_html, content_type="text/html")
|
||||
|
||||
code = await self.oidc_provider.async_save_user_info(user_details)
|
||||
|
||||
return web.HTTPFound(get_url("/auth/oidc/finish?code=" + code))
|
||||
|
||||
Reference in New Issue
Block a user