Update logic for creating a new user to use aupdate_or_create

This commit is contained in:
sabaimran 2023-11-15 12:50:39 -08:00
parent b8e7488a95
commit b63856ecb4

View file

@ -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(