forked from e621ng/e621ng
Make recaptcha optional on signup page.
This commit is contained in:
parent
2000719227
commit
8d8a2f9c1e
@ -44,7 +44,7 @@ class UsersController < ApplicationController
|
||||
def create
|
||||
@user = User.new(params[:user], :as => CurrentUser.role)
|
||||
@user.last_ip_addr = request.remote_ip
|
||||
if verify_recaptcha(model: @user)
|
||||
if !Danbooru.config.enable_recaptcha? || verify_recaptcha(model: @user)
|
||||
@user.save
|
||||
if @user.errors.empty?
|
||||
session[:user_id] = @user.id
|
||||
|
@ -15,7 +15,11 @@
|
||||
<%= f.input :password %>
|
||||
<%= f.input :password_confirmation %>
|
||||
|
||||
<%= invisible_recaptcha_tags callback: 'submitInvisibleRecaptchaForm', text: 'Sign up' %>
|
||||
<% if Danbooru.config.enable_recaptcha? %>
|
||||
<%= invisible_recaptcha_tags callback: 'submitInvisibleRecaptchaForm', text: 'Sign up' %>
|
||||
<% else %>
|
||||
<%= f.submit "Sign up", :data => { :disable_with => "Signing up..." } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -619,6 +619,18 @@ module Danbooru
|
||||
|
||||
def aws_sqs_cropper_url
|
||||
end
|
||||
|
||||
# Use a recaptcha on the signup page to protect against spambots creating new accounts.
|
||||
# https://developers.google.com/recaptcha/intro
|
||||
def enable_recaptcha?
|
||||
Rails.env.production? && Danbooru.config.recaptcha_site_key.present? && Danbooru.config.recaptcha_secret_key.present?
|
||||
end
|
||||
|
||||
def recaptcha_site_key
|
||||
end
|
||||
|
||||
def recaptcha_secret_key
|
||||
end
|
||||
end
|
||||
|
||||
class EnvironmentConfiguration
|
||||
|
5
config/initializers/recaptcha.rb
Normal file
5
config/initializers/recaptcha.rb
Normal file
@ -0,0 +1,5 @@
|
||||
Recaptcha.configure do |config|
|
||||
config.site_key = Danbooru.config.recaptcha_site_key
|
||||
config.secret_key = Danbooru.config.recaptcha_secret_key
|
||||
# config.proxy = "http://example.com"
|
||||
end
|
@ -76,11 +76,7 @@ class UsersControllerTest < ActionController::TestCase
|
||||
|
||||
context "new action" do
|
||||
setup do
|
||||
ENV["RECAPTCHA_SITE_KEY"] = "x"
|
||||
end
|
||||
|
||||
teardown do
|
||||
ENV["RECAPTCHA_SITE_KEY"] = nil
|
||||
Danbooru.config.stubs(:enable_recaptcha?).returns(false)
|
||||
end
|
||||
|
||||
should "render" do
|
||||
|
Loading…
Reference in New Issue
Block a user