2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-17 18:04:11 +08:00

FIX: Hcaptcha plugin was incompatible with login-required sites (#34181)

This commit is contained in:
Penar Musaraj 2025-08-08 14:37:57 -04:00 committed by GitHub
parent 730598ef16
commit eec7ecac7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -5,6 +5,8 @@ module ::DiscourseHcaptcha
requires_plugin DiscourseHcaptcha::PLUGIN_NAME
before_action :ensure_config
skip_before_action :redirect_to_login_if_required
TOKEN_TTL = 2.minutes
protect_from_forgery except: [:create]

View file

@ -56,6 +56,16 @@ RSpec.describe "Users", type: :request do
post "/u.json", params: user_params
expect(JSON.parse(response.body)["success"]).to be(true)
end
context "when site is login-required" do
before { SiteSetting.login_required = true }
it "succeeds in registration" do
post "/hcaptcha/create.json", params: { token: "token-from-hCaptcha" }
post "/u.json", params: user_params
expect(JSON.parse(response.body)["success"]).to be(true)
end
end
end
context "when h_captcha is disabled" do