Skip to content

Conversation

@Dantemss
Copy link
Member

@Dantemss Dantemss commented May 27, 2025

  • Initial attempt at adding reCAPTCHA to Accounts
  • Fully removed legacy signup controller, views, routes

@Dantemss Dantemss self-assigned this May 27, 2025
@Dantemss Dantemss requested a review from mwvolo May 27, 2025 18:35
@Dantemss Dantemss marked this pull request as ready for review May 27, 2025 18:35
@Dantemss
Copy link
Member Author

Well I haven't tested this yet at all, but maybe you can take a look.

@github-actions
Copy link

❌ Migration check failed. Check the workflow run for details.

@openstax openstax deleted a comment from github-actions bot Jun 4, 2025
@openstax openstax deleted a comment from github-actions bot Jun 4, 2025
@openstax openstax deleted a comment from github-actions bot Jun 4, 2025
@openstax openstax deleted a comment from github-actions bot Jun 4, 2025
@openstax openstax deleted a comment from github-actions bot Jun 4, 2025
@openstax openstax deleted a comment from github-actions bot Jun 12, 2025
@openstax openstax deleted a comment from github-actions bot Jun 12, 2025
@openstax openstax deleted a comment from github-actions bot Jun 12, 2025
@Dantemss
Copy link
Member Author

@mwvolo this should be ready for review, though there are still some flaky feature specs

@mwvolo mwvolo requested a review from Copilot June 30, 2025 22:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds Google reCAPTCHA to the new Sign-up flows and removes legacy signup controllers, views, and routes.

  • Introduces recaptcha gem configuration, view helpers, and verification in signup controllers
  • Injects reCAPTCHA widgets into student and educator signup/change-email forms
  • Cleans up legacy signup code and updates feature specs to use Capybara’s have_current_path matcher

Reviewed Changes

Copilot reviewed 32 out of 34 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
config/secrets.yml Adds recaptcha.site_key and secret_key entries
config/initializers/recaptcha.rb Configures Recaptcha gem, stub behavior for non-prod
app/controllers/newflow/signup_controller.rb Includes RecaptchaController helper
app/controllers/newflow/student_signup_controller.rb Adds verify_recaptcha_with_fallback around signup
app/controllers/newflow/educator_signup_controller.rb Adds verify_recaptcha_with_fallback around signup
app/views/newflow/**/*_signup_form.html.erb Injects <%= recaptcha_with_disclaimer_and_fallback %>
app/views/newflow/signup/_change_signup_email_form_template… Injects recaptcha into email-change form
config/routes.rb Removes legacy signup routes
app/views/legacy/signup/** and app/controllers/legacy/**/* Entire legacy signup flow removed
spec/**/*.rb Replaces expect(page.current_path) with have_current_path and related matcher updates
Comments suppressed due to low confidence (2)

config/initializers/recaptcha.rb:47

  • No existing feature specs cover the fallback case when reCAPTCHA verification fails (i.e. force_recaptcha_failure is true). Consider adding an integration test that injects force_recaptcha_failure: 'true' to verify that the form re-renders with the failure message.
    force_recaptcha_failure = params[:force_recaptcha_failure] == 'true'

README.md:167

  • [nitpick] It would be helpful to document how to configure the new reCAPTCHA keys (e.g. RECAPTCHA_SITE_KEY and RECAPTCHA_SECRET_KEY environment variables) in the README under a new "reCAPTCHA Configuration" section.
The most straightforward way to sign up is by visiting the `newflow_signup_path`  without any parameters in the URL and without any state in the session.

Comment on lines 12 to +13
render :student_signup_form
}
)
if verify_recaptcha_with_fallback
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The if verify_recaptcha_with_fallback ... else blocks in both StudentSignupController and EducatorSignupController duplicate the rendering logic. Consider extracting the recaptcha check into a shared before_action or method to DRY up these controllers.

Suggested change
def student_signup
handle_with(
StudentSignup::SignupForm,
contracts_required: !contracts_not_required,
client_app: get_client_app,
success: lambda {
user = @handler_result.outputs.user
save_unverified_user(user.id)
security_log(:student_signed_up, { user: user })
log_posthog(user, "student_started_signup")
redirect_to student_email_verification_form_path
},
failure: lambda {
email = @handler_result.outputs.email
error_codes = @handler_result.errors.map(&:code)
security_log(:student_sign_up_failed, { reason: error_codes, email: email })
render :student_signup_form
}
)
if verify_recaptcha_with_fallback
private
def handle_recaptcha_failure(failure_view)
if verify_recaptcha_with_fallback
yield
else
instance_variable_set(:@email, unverified_user.email_addresses.first.value) if failure_view == :student_change_signup_email_form
render failure_view
end
end
def student_signup
handle_recaptcha_failure(:student_signup_form) do

Copilot uses AI. Check for mistakes.
def maybe_skip_to_sign_up
if %w{signup student_signup}.include?(params[:go])
redirect_to signup_path(set_param_to_permit_legacy_flow)
redirect_to newflow_signup_path
Copy link
Member

Choose a reason for hiding this comment

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

do we still use this? I think this was a Tutor thing

Copy link
Member Author

Choose a reason for hiding this comment

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

we can maybe remove this then

Copy link
Member

Choose a reason for hiding this comment

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

I saw you message asking about this, but I'm going to go ahead and merge this to unblock Roy's PRs.
We can open another one to clean up remaining legacy stuff.

def password; end
def social; end

def profile
Copy link
Member

Choose a reason for hiding this comment

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

is stuff staying here for specs / making migration easier? I don't think (hope) this profile method isn't called.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's called somewhere but all it does is redirect

Copy link
Member Author

Choose a reason for hiding this comment

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

Nvm I got that wrong, it doesn't just redirect. It's called from here:

redirect_to '/signup/profile' if current_user.is_needs_profile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@mwvolo mwvolo left a comment

Choose a reason for hiding this comment

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

looks good to me, asked a few questions, but not blocking merge

@openstax openstax deleted a comment from github-actions bot Jul 9, 2025
@openstax openstax deleted a comment from github-actions bot Jul 9, 2025
@openstax openstax deleted a comment from github-actions bot Jul 9, 2025
@openstax openstax deleted a comment from github-actions bot Jul 9, 2025
@openstax openstax deleted a comment from github-actions bot Jul 9, 2025
@mwvolo mwvolo merged commit 6305d61 into main Jul 9, 2025
6 of 7 checks passed
@mwvolo mwvolo deleted the captcha branch July 9, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants