Skip to content
Draft
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
10 changes: 5 additions & 5 deletions app/controllers/course/enrol_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def create
end

def create_unauthenticated # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
unless verify_recaptcha
render json: { errors: { recaptcha: t('errors.user.registrations.verify_recaptcha_alert') } },
status: :unprocessable_entity
return
end
# unless verify_recaptcha
# render json: { errors: { recaptcha: t('errors.user.registrations.verify_recaptcha_alert') } },
# status: :unprocessable_entity
# return
# end
Comment on lines +29 to +33
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The reCAPTCHA gate in create_unauthenticated has been commented out, which removes the only bot/abuse protection for a publicly accessible endpoint that creates enrol requests and sends emails. This is a security/operational regression (spam enrol requests, mail queue flooding). Please restore the verify_recaptcha check (or gate the bypass behind an explicit config/feature flag limited to non-production environments), and remove the commented-out block once the intended behavior is implemented.

Suggested change
# unless verify_recaptcha
# render json: { errors: { recaptcha: t('errors.user.registrations.verify_recaptcha_alert') } },
# status: :unprocessable_entity
# return
# end
if Rails.env.production? && !verify_recaptcha
render json: { errors: { recaptcha: t('errors.user.registrations.verify_recaptcha_alert') } },
status: :unprocessable_entity
return
end

Copilot uses AI. Check for mistakes.

user_id = create_unauthenticated_params.to_i
user = User.find_by(id: user_id)
Expand Down