Skip to content

Commit

Permalink
fix: patreon changed auth API and broke legacy users
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Oct 18, 2024
1 parent 9f2f05e commit f44133e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion authn/providers/patreon.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def parse_active_membership(user_data: dict) -> Optional[Membership]:
platform=Platform.patreon,
user_id=user_data["data"]["id"],
full_name=user_data["data"]["attributes"]["full_name"],
email=user_data["data"]["attributes"]["email"],
email=user_data["data"]["attributes"].get("email"), # since 2024 may be optional =/
image=None, # user_data["data"]["attributes"]["image_url"],
started_at=membership_started_at,
charged_at=last_charged_at,
Expand Down
10 changes: 9 additions & 1 deletion authn/views/patreon.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def patreon_sync_callback(request):
"Проверьте, всё ли там у них в порядке."
}, status=402)

if request.me.email.lower() != membership.email.lower():
if membership.email and request.me.email.lower() != membership.email.lower():
# user and patreon emails do not match
return render(request, "error.html", {
"title": "⛔️ Ваш email не совпадает с патреоновским",
Expand All @@ -84,6 +84,14 @@ def patreon_sync_callback(request):
"По нашим данным, вы уже перешли на более совершенный вид оплаты и вернуться назад не получится."
}, status=400)

if request.me.patreon_id != membership.user_id:
# wrong patreon id
return render(request, "error.html", {
"title": "⛔️ Кажется это не ваш патреон",
"message": "Ваш ID на патреоне не совпадает с тем, который записан у нас. "
"Скорее всего вы используете не тот аккаунт."
}, status=400)

# update membership dates
if membership.expires_at > request.me.membership_expires_at:
request.me.membership_expires_at = membership.expires_at
Expand Down

0 comments on commit f44133e

Please sign in to comment.