mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Update logic for creating a new user to use aupdate_or_create
This commit is contained in:
parent
b8e7488a95
commit
b63856ecb4
1 changed files with 4 additions and 4 deletions
|
@ -80,9 +80,9 @@ async def get_or_create_user(token: dict) -> KhojUser:
|
||||||
|
|
||||||
|
|
||||||
async def create_user_by_token(token: dict) -> KhojUser:
|
async def create_user_by_token(token: dict) -> KhojUser:
|
||||||
user = await KhojUser.objects.filter(email=token.get("email")).aget_or_none()
|
user = await KhojUser.objects.filter(email=token.get("email")).aupdate_or_create(
|
||||||
if not user:
|
defaults={"username": token.get("email"), "email": token.get("email")}
|
||||||
user = await KhojUser.objects.acreate(username=token.get("email"), email=token.get("email"))
|
)
|
||||||
await user.asave()
|
await user.asave()
|
||||||
|
|
||||||
await GoogleUser.objects.acreate(
|
await GoogleUser.objects.acreate(
|
||||||
|
|
Loading…
Reference in a new issue