0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/plugins/discourse-hcaptcha/plugin.rb
Gabriel Grubba eccaa62a85
FEATURE: Add recaptcha provider to hcaptcha plugin (#39018)
This is a revival of this PR:
https://github.com/discourse/discourse/pull/33636


### Description
This PR adds ReCaptcha as a Captcha provider and provides a refactor to
allow other Captcha providers to be added more easily. To achieve this,
the following changes were introduced:


- Provider Pattern Introduction in
lib/discourse_hcaptcha/captcha_provider.rb
- Controller refactoring, created a new Parent controller, extracted
common logic
- Serializer for each captcha provider
- Implemented base abstract component for FE captcha logic
- h-captcha-service is now provider agnostic (captcha-service) and
manages both captcha providers
- Added connectors to the UI to allow the chosen captcha to be rendered
- Added problem check and site settings for the newly introduced
ReCaptcha
- `before-create-account` valueTransformer is introduced to allow
captcha validation (or any other data) without modifying the class.

---------

Co-authored-by: Juan Martinez <juan@discourse.org>
Co-authored-by: David Taylor <david@taylorhq.com>
2026-06-09 09:08:26 -05:00

30 lines
924 B
Ruby
Vendored

# coding: utf-8
# frozen_string_literal: true
# name: discourse-hcaptcha
# about: hCaptcha support for Discourse
# version: 0.0.1
# authors: Discourse
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-hcaptcha
# required_version: 2.7.0
# meta_topic_id: 291383
enabled_site_setting :discourse_captcha_enabled
register_svg_icon "hand"
module ::DiscourseHcaptcha
PLUGIN_NAME = "discourse-hcaptcha"
end
require_relative "lib/discourse_hcaptcha/engine"
require_relative "lib/discourse_hcaptcha/captcha_provider"
after_initialize do
reloadable_patch { UsersController.include(DiscourseHcaptcha::CreateUsersControllerPatch) }
require_relative "app/services/problem_check/hcaptcha_configuration"
require_relative "app/services/problem_check/recaptcha_configuration"
register_problem_check ProblemCheck::HcaptchaConfiguration
register_problem_check ProblemCheck::RecaptchaConfiguration
end