Skip to content

Commit

Permalink
Ingress does not break when username missing (#4551)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 authored Sep 11, 2023
1 parent 44daffc commit 32da679
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions supervisor/api/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ def _init_header(

if session_data is not None:
headers[HEADER_REMOTE_USER_ID] = session_data.user.id
headers[HEADER_REMOTE_USER_NAME] = session_data.user.username
headers[HEADER_REMOTE_USER_DISPLAY_NAME] = session_data.user.display_name
if session_data.user.username is not None:
headers[HEADER_REMOTE_USER_NAME] = session_data.user.username
if session_data.user.display_name is not None:
headers[HEADER_REMOTE_USER_DISPLAY_NAME] = session_data.user.display_name

# filter flags
for name, value in request.headers.items():
Expand Down
4 changes: 2 additions & 2 deletions supervisor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ class IngressSessionDataUser:
"""Format of an IngressSessionDataUser object."""

id: str
display_name: str
username: str
display_name: str | None = None
username: str | None = None


@dataclass
Expand Down
4 changes: 3 additions & 1 deletion supervisor/homeassistant/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ async def get_users(self) -> list[IngressSessionDataUser]:

return [
IngressSessionDataUser(
id=data["id"], username=data["username"], display_name=data["name"]
id=data["id"],
username=data.get("username"),
display_name=data.get("name"),
)
for data in list_of_users
]

0 comments on commit 32da679

Please sign in to comment.