Skip to content

Commit aa1a852

Browse files
authored
Merge pull request #4 from reflex-dev/user-info-total-false
Mark AzureUserInfo as total=False
2 parents c28d574 + ca924b8 commit aa1a852

File tree

2 files changed

+1505
-1205
lines changed

2 files changed

+1505
-1205
lines changed

reflex_azure_auth/types.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
"""Shared types and helpers for Azure user info."""
22

3-
from typing import TypedDict
3+
from typing import Required, TypedDict
44

55

6-
class AzureUserInfo(TypedDict):
6+
class AzureUserInfo(TypedDict, total=False):
77
"""TypedDict representing user information from Azure / Microsoft identity platform.
88
99
Contains user profile data returned by the /userinfo endpoint following
1010
successful authentication (OpenID Connect standard claims).
1111
"""
1212

13-
sub: str
14-
email: str | None
15-
name: str | None
16-
given_name: str | None
17-
middle_name: str | None
18-
family_name: str | None
19-
picture: str | None
20-
locale: str | None
13+
sub: Required[str]
14+
email: str
15+
name: str
16+
given_name: str
17+
middle_name: str
18+
family_name: str
19+
picture: str
20+
locale: str
2121

2222

2323
# Microsoft API returns these without the underscore... not sure why
@@ -33,13 +33,4 @@ def user_info_from_dict(data: dict) -> AzureUserInfo:
3333
for mapped_name, real_name in user_info_mapping.items():
3434
if mapped_name in data and real_name not in data:
3535
data[real_name] = data.pop(mapped_name)
36-
return AzureUserInfo(
37-
sub=data["sub"],
38-
email=data.get("email"),
39-
name=data.get("name"),
40-
given_name=data.get("given_name"),
41-
middle_name=data.get("middle_name"),
42-
family_name=data.get("family_name"),
43-
picture=data.get("picture"),
44-
locale=data.get("locale"),
45-
)
36+
return AzureUserInfo(**data)

0 commit comments

Comments
 (0)