Skip to content

Commit

Permalink
Gives 0 credits when signing up using email
Browse files Browse the repository at this point in the history
  • Loading branch information
clr-li committed Oct 8, 2023
1 parent 86c62ef commit 8428016
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app_users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def copy_from_firebase_user(self, user: auth.UserRecord) -> "AppUser":
self.display_name = user.display_name or ""
self.email = user.email
self.phone_number = user.phone_number
provider_list = user.provider_data
self.created_at = timezone.datetime.fromtimestamp(
user.user_metadata.creation_timestamp / 1000
)
Expand All @@ -175,14 +176,15 @@ def copy_from_firebase_user(self, user: auth.UserRecord) -> "AppUser":
self.is_anonymous = is_anonymous_now

# get existing balance or set free credits
default_balance = settings.LOGIN_USER_FREE_CREDITS
if self.is_anonymous:
default_balance = settings.ANON_USER_FREE_CREDITS
elif provider_list[-1].provider_id == "password":
default_balance = settings.EMAIL_USER_FREE_CREDITS
self.balance = db.get_doc_field(
doc_ref=db.get_user_doc_ref(user.uid),
field=db.USER_BALANCE_FIELD,
default=(
settings.ANON_USER_FREE_CREDITS
if self.is_anonymous
else settings.LOGIN_USER_FREE_CREDITS
),
default=default_balance,
)

return self
Expand Down
1 change: 1 addition & 0 deletions daras_ai_v2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
SAFTY_CHECKER_BILLING_EMAIL = "[email protected]"

CREDITS_TO_DEDUCT_PER_RUN = config("CREDITS_TO_DEDUCT_PER_RUN", 5, cast=int)
EMAIL_USER_FREE_CREDITS = config("EMAIL_USER_FREE_CREDITS", 0, cast=int)
ANON_USER_FREE_CREDITS = config("ANON_USER_FREE_CREDITS", 25, cast=int)
LOGIN_USER_FREE_CREDITS = config("LOGIN_USER_FREE_CREDITS", 1000, cast=int)

Expand Down

0 comments on commit 8428016

Please sign in to comment.