mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-05 21:29:11 +00:00
Only create subscription object when it does not exist for user
This avoid unnecessarily throwing an internal server error when the user tries to sign-up using multiple mechanisms (e.g first by email, then by google oauth)
This commit is contained in:
@@ -224,7 +224,9 @@ async def acreate_user_by_phone_number(phone_number: str) -> KhojUser:
|
|||||||
)
|
)
|
||||||
await user.asave()
|
await user.asave()
|
||||||
|
|
||||||
await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
|
user_subscription = await Subscription.objects.filter(user=user).afirst()
|
||||||
|
if not user_subscription:
|
||||||
|
await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@@ -296,7 +298,9 @@ async def create_user_by_google_token(token: dict) -> KhojUser:
|
|||||||
user=user,
|
user=user,
|
||||||
)
|
)
|
||||||
|
|
||||||
await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
|
user_subscription = await Subscription.objects.filter(user=user).afirst()
|
||||||
|
if not user_subscription:
|
||||||
|
await Subscription.objects.acreate(user=user, type=Subscription.Type.STANDARD)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user