mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 11:15:10 +08:00
#### Description:
This PR renames the `discourse-hcaptcha` plugin to `discourse-captcha`
to better reflect its support for multiple captcha providers (hCaptcha
and reCAPTCHA)
#### Changes
- Renamed plugin directory from plugins/discourse-hcaptcha to
plugins/discourse-captcha
- Updated Ruby module namespace from DiscourseHcaptcha to
DiscourseCaptcha
- Updated references in:
- .gitignore
- pnpm-workspace.yaml
- tsconfig.json
- config/official_plugins.json
- translator.yml
- migrations/core/config/intermediate_db.yml
- `hosted-site` plugin
- Migration file preserved to handle existing discourse_hcaptcha_enabled
setting migration
---------
Co-authored-by: Gabriel Grubba <gabriel@discourse.org>
35 lines
829 B
Ruby
Vendored
35 lines
829 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseCaptcha
|
|
class CaptchaProvider
|
|
HCAPTCHA = "hcaptcha"
|
|
RECAPTCHA = "recaptcha"
|
|
NONE = "none"
|
|
|
|
def fetch_captcha_token(server_session)
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def captcha_verification_url
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def send_captcha_verification(captcha_token)
|
|
raise NotImplementedError
|
|
end
|
|
|
|
protected
|
|
|
|
def send_verification(captcha_token, captcha_verification_url, secret_key)
|
|
uri = URI.parse(captcha_verification_url)
|
|
|
|
http = FinalDestination::HTTP.new(uri.host, uri.port)
|
|
http.use_ssl = true
|
|
|
|
request = FinalDestination::HTTP::Post.new(uri.request_uri)
|
|
request.set_form_data({ "secret" => secret_key, "response" => captcha_token })
|
|
|
|
http.request(request)
|
|
end
|
|
end
|
|
end
|