Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #622

Merged
merged 9 commits into from
Sep 14, 2024
11 changes: 11 additions & 0 deletions brightIDfaucet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from dotenv import load_dotenv
from sentry_sdk.integrations.django import DjangoIntegration

from corsheaders.defaults import default_headers

from faucet.faucet_manager.bright_id_interface import BrightIDInterface

load_dotenv()
Expand Down Expand Up @@ -244,6 +246,15 @@ def before_send(event, hint):
else:
CORS_ALLOW_ALL_ORIGINS = True


# Add Turnstile response headers for CORS
# These headers are required for Cloudflare and HCaptcha Turnstile anti-bot service

CORS_ALLOW_HEADERS = list(default_headers) + [
'cf-turnstile-response',
'hc-turnstile-response',
]

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

Expand Down
4 changes: 2 additions & 2 deletions core/constraints/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_observed(self, *args, **kwargs) -> bool:
context["request"]
)

turnstile_token = request_context.data.get("cf-turnstile-response")
turnstile_token = request_context.headers.get("cf-turnstile-response")

return request_context.ip is not None and turnstile_token is not None and cloudflare.is_verified(
turnstile_token, request_context.ip
Expand Down Expand Up @@ -60,7 +60,7 @@ def is_observed(self, *args, **kwargs) -> bool:
context["request"]
)

turnstile_token = request_context.data.get("cf-turnstile-response")
turnstile_token = request_context.headers.get("hc-turnstile-response")

return request_context.ip is not None and turnstile_token is not None and hcaptcha.is_verified(
turnstile_token, request_context.ip
Expand Down
4 changes: 2 additions & 2 deletions core/constraints/zora.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class DidMintZoraNFT(ConstraintVerification):
app_name = ConstraintApp.ZORA.value
_param_keys = [ConstraintParam.ADDRESS]

def __init__(self, user_profile) -> None:
super().__init__(user_profile)
def __init__(self, user_profile, *, obj=None) -> None:
super().__init__(user_profile, obj=obj)

def is_observed(self, *args, **kwargs) -> bool:
zora_util = ZoraUtil()
Expand Down
32 changes: 32 additions & 0 deletions prizetap/migrations/0079_fix_raffle_image_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.0.4 on 2024-08-25 09:12

from django.db import migrations, models


def fix_raffle_images_prefix(apps, schema):
Raffle = apps.get_model("prizetap", "Raffle")

raffles = Raffle.objects.all()

for raffle in raffles:
if (
raffle.image
and raffle.image.name
and raffle.image.name.startswith("https://imagedelivery.net")
):
# split the url to get the image id
raffle.image.name = raffle.image.name.split("/")[-2]
raffle.save()


class Migration(migrations.Migration):

dependencies = [
("prizetap", "0078_alter_constraint_name"),
]

operations = [
migrations.RunPython(
fix_raffle_images_prefix, reverse_code=migrations.RunPython.noop
)
]
40 changes: 40 additions & 0 deletions tokenTap/migrations/0065_fix_token_image_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.0.4 on 2024-08-25 09:12

from django.db import migrations, models


def fix_token_images_prefix(apps, schema_editor):
TokenDistribution = apps.get_model("tokenTap", "TokenDistribution")

tokens = TokenDistribution.objects.all()

for token in tokens:
if (
token.image
and token.image.name
and token.image.name.startswith("https://imagedelivery.net")
):
# split the url to get the image id
token.image.name = token.image.name.split("/")[-2]
token.save()

if (
token.token_image
and token.token_image.name
and token.token_image.name.startswith("https://imagedelivery.net")
):
token.token_image.name = token.token_image.name.split("/")[-2]
token.save()


class Migration(migrations.Migration):

dependencies = [
("tokenTap", "0064_alter_constraint_name"),
]

operations = [
migrations.RunPython(
fix_token_images_prefix, reverse_code=migrations.RunPython.noop
)
]
Loading