-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6971d0
commit e8f453a
Showing
2 changed files
with
27 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,15 @@ 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) | ||
|
||
"""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, token: str) -> User: | ||
user = User.create(email=email, password=None) | ||
if provider == "github": | ||
|
@@ -131,7 +135,21 @@ async def delete_api_key(self, token: APIKey | str) -> None: | |
|
||
async def test_adhoc() -> None: | ||
async with UserCrud() as crud: | ||
await crud._create_user_from_email(email="[email protected]", password="examplepas$w0rd") | ||
# Test standard user creation | ||
user = await crud._create_user_from_email(email="[email protected]", password="examplepas$w0rd") | ||
print(f"User created: {user}") | ||
|
||
# Test OAuth user creation (GitHub) | ||
oauth_user_github = await crud.get_user_from_github_token( | ||
token="gh_token_example", email="[email protected]" | ||
) | ||
print(f"OAuth GitHub User created: {oauth_user_github}") | ||
|
||
# Test OAuth user creation (Google) | ||
oauth_user_google = await crud.get_user_from_google_token( | ||
token="google_token_example", email="[email protected]" | ||
) | ||
print(f"OAuth Google User created: {oauth_user_google}") | ||
|
||
|
||
if __name__ == "__main__": | ||
|
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