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

Tighten account creation validations #10486

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jimchamp
Copy link
Collaborator

Ensures that legitimately invalid ReCaptcha tests cause account creation form validations to fail.

Technical

Testing

Screenshot

Stakeholders

Comment on lines +10 to +17
INVALIDATING_ERRORS = [
"invalid-input-secret",
"missing-input-secret",
"missing-input-response",
"invalid-input-response",
"bad-request",
"timeout-or-duplicate",
]
Copy link
Collaborator Author

@jimchamp jimchamp Feb 20, 2025

Choose a reason for hiding this comment

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

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm! Good catch. One non blocking suggestion 👍

@@ -38,6 +50,6 @@ def validate(self, value=None):
data = r.json()
if not data.get('success', False) and 'error-codes' in data:
logger.error(f"Recaptcha Error: {data['error-codes']}")
return True
return accept_error(data['error-codes'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be more easily done with some set logic:

Suggested change
return accept_error(data['error-codes'])
return not (set(data['error-codes']) & INVALIDATING_ERRORS)

Ie check that the provided errors don't intersect the invalidating errors. But it's the same, so just a suggestion.

@jimchamp jimchamp added the Patch Deployed This PR has been deployed to production independently, outside of the regular deploy cycle. label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Patch Deployed This PR has been deployed to production independently, outside of the regular deploy cycle.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants