|
27 | 27 |
|
28 | 28 |
|
29 | 29 | class Auth(AuthCredentials):
|
| 30 | + """Extended auth credentials schema based on Starlette AuthCredentials.""" |
| 31 | + |
30 | 32 | http: bool
|
31 | 33 | secret: str
|
32 | 34 | expires: int
|
@@ -69,23 +71,27 @@ def jwt_create(cls, token_data: dict) -> str:
|
69 | 71 |
|
70 | 72 |
|
71 | 73 | class User(BaseUser, dict):
|
72 |
| - def __init__(self, seq: Optional[dict] = None, **kwargs) -> None: |
73 |
| - super().__init__(seq or {}, **kwargs) |
74 |
| - self._is_authenticated = seq is not None |
75 |
| - self._identity = self.get("identity", "") |
76 |
| - self._display_name = self.get("display_name", "") |
| 74 | + """Extended user schema based on Starlette BaseUser.""" |
77 | 75 |
|
78 | 76 | @property
|
79 | 77 | def is_authenticated(self) -> bool:
|
80 |
| - return self._is_authenticated |
| 78 | + return bool(self) |
81 | 79 |
|
82 | 80 | @property
|
83 | 81 | def display_name(self) -> str:
|
84 |
| - return self._display_name |
| 82 | + return self.get("display_name", "") # name |
85 | 83 |
|
86 | 84 | @property
|
87 | 85 | def identity(self) -> str:
|
88 |
| - return self._identity |
| 86 | + return self.get("identity", "") # username |
| 87 | + |
| 88 | + @property |
| 89 | + def picture(self) -> str: |
| 90 | + return self.get("picture", "") # image |
| 91 | + |
| 92 | + @property |
| 93 | + def email(self) -> str: |
| 94 | + return self.get("email", "") # email |
89 | 95 |
|
90 | 96 |
|
91 | 97 | class OAuth2Backend(AuthenticationBackend):
|
|
0 commit comments