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

Fix/requirements/captcha and zora #619

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/constraints/captcha.py
Original file line number Diff line number Diff line change
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.data.get("hc-turnstile-response") or request_context.data.get("cf-turnstile-response")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment explaining the reason for supporting multiple CAPTCHA providers

It would be helpful to add a brief comment explaining why both 'hc-turnstile-response' and 'cf-turnstile-response' are being checked. Additionally, consider defining these as constants to avoid string duplication and improve maintainability.

Suggested change
turnstile_token = request_context.data.get("hc-turnstile-response") or request_context.data.get("cf-turnstile-response")
HC_TURNSTILE_KEY = "hc-turnstile-response"
CF_TURNSTILE_KEY = "cf-turnstile-response"
turnstile_token = request_context.data.get(HC_TURNSTILE_KEY) or request_context.data.get(CF_TURNSTILE_KEY)


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
Loading