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,10 +80,10 @@ async def get_or_create_user(token: dict) -> KhojUser:
|
|||
|
||||
|
||||
async def create_user_by_token(token: dict) -> KhojUser:
|
||||
user = await KhojUser.objects.filter(email=token.get("email")).aget_or_none()
|
||||
if not user:
|
||||
user = await KhojUser.objects.acreate(username=token.get("email"), email=token.get("email"))
|
||||
await user.asave()
|
||||
user = await KhojUser.objects.filter(email=token.get("email")).aupdate_or_create(
|
||||
defaults={"username": token.get("email"), "email": token.get("email")}
|
||||
)
|
||||
await user.asave()
|
||||
|
||||
await GoogleUser.objects.acreate(
|
||||
sub=token.get("sub"),
|
||||
|
|
Loading…
Reference in a new issue