Add comprehensive email validation for blocked users#3
Conversation
… many times each email address is blocked, and last time it was blocked. Move email validation out of User model and into EmailValidator. Signup form remembers which email addresses have failed and shows validation error on email field.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f8a130277
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| record = BlockedEmail.where(email: email).first | ||
| if record | ||
| record.match_count += 1 | ||
| record.last_match_at = Time.zone.now | ||
| record.save |
There was a problem hiding this comment.
Prevent double-counting blocked email matches
BlockedEmail.should_block? updates match_count/last_match_at every time validation runs. In UsersController#create, validations are invoked once via user.valid? (before the DiscourseHub call) and again by user.save, so a single blocked signup attempt will increment match_count twice. This skews the new blocked-email statistics and any downstream logic that relies on them; consider deferring the stats update until after a single failed save, or guarding against repeated validations in the same request.
Useful? React with 👍 / 👎.
Test 3
Replicated from ai-code-review-evaluation/discourse-cursor#3