-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improved listing grid * format * formatting * dict -> model dump
- Loading branch information
1 parent
b750146
commit 8c19cb8
Showing
5 changed files
with
66 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,23 +47,17 @@ async def get_user(self, id: str, throw_if_missing: bool = False) -> User | None | |
async def get_user(self, id: str, throw_if_missing: bool = False) -> User | None: | ||
return await self._get_item(id, User, throw_if_missing=throw_if_missing) | ||
|
||
"""For safely retrieving public user data for display on profile pages""" | ||
|
||
async def get_user_public(self, id: str, throw_if_missing: bool = False) -> UserPublic | None: | ||
user = await self.get_user(id, throw_if_missing=throw_if_missing) | ||
if user is None: | ||
return None | ||
return UserPublic(**user.model_dump()) | ||
|
||
"""Standard sign up with email and password, leaves oauth providers empty""" | ||
|
||
async def _create_user_from_email(self, email: str, password: str) -> User: | ||
user = User.create(email=email, password=password) | ||
await self._add_item(user, unique_fields=["email"]) | ||
return user | ||
|
||
"""OAuth sign up, creates user and links OAuthKey""" | ||
|
||
async def _create_user_from_oauth(self, email: str, provider: str, user_token: str) -> User: | ||
user = await self.get_user_from_email(email) | ||
if user is None: | ||
|
@@ -195,9 +189,7 @@ async def update_user(self, user_id: str, updates: dict[str, Any]) -> User: | |
async def test_adhoc() -> None: | ||
async with UserCrud() as crud: | ||
await crud._create_user_from_email(email="[email protected]", password="examplepas$w0rd") | ||
|
||
await crud.get_user_from_github_token(token="gh_token_example", email="[email protected]") | ||
|
||
await crud.get_user_from_google_token(email="[email protected]") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters