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:
parent
730598ef16
commit
eec7ecac7e
2 changed files with 12 additions and 0 deletions
|
@ -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]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue