add method to replace gotcha
This commit is contained in:
parent
fb2d53d513
commit
1e7d5c52c9
|
@ -0,0 +1,21 @@
|
|||
RuCaptcha.configure do
|
||||
# Color style, default: :colorful, allows: [:colorful, :black_white]
|
||||
# self.style = :colorful
|
||||
# Custom captcha code expire time if you need, default: 2 minutes
|
||||
# self.expires_in = 120
|
||||
# [Requirement / 重要]
|
||||
# Store Captcha code where, this config more like Rails config.cache_store
|
||||
# default: Read config info from `Rails.application.config.cache_store`
|
||||
# But RuCaptcha requirements cache_store not in [:null_store, :memory_store, :file_store]
|
||||
# 默認:會從 Rails 配置的 cache_store 里面讀取相同的配置信息,並嘗試用可以運行的方式,用於存儲驗證碼字符
|
||||
# 但如果是 [:null_store, :memory_store, :file_store] 之类的,你可以通過下面的配置項單獨給 RuCaptcha 配置 cache_store
|
||||
self.cache_store = :file_store
|
||||
# 如果想要 disable cache_store 的 warning,就設置為 true,default false
|
||||
# self.skip_cache_store_check = true
|
||||
# Chars length, default: 5, allows: [3 - 7]
|
||||
# self.length = 5
|
||||
# enable/disable Strikethrough.
|
||||
# self.strikethrough = true
|
||||
# enable/disable Outline style
|
||||
# self.outline = false
|
||||
end
|
|
@ -1,3 +1,5 @@
|
|||
en:
|
||||
rucaptcha:
|
||||
invalid: "The captcha code is incorrect (if you can't read, you can click image to refresh it)"
|
||||
placeholder: please fill in the identifying code
|
||||
captcha: Captcha
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
zh_tw:
|
||||
rucaptcha:
|
||||
placeholder: 請填寫驗證碼
|
||||
captcha: 驗證碼
|
|
@ -44,6 +44,9 @@ module RuCaptcha
|
|||
# verify_rucaptcha?(nil, keep_session: true)
|
||||
# verify_rucaptcha?(nil, captcha: params[:user][:captcha])
|
||||
#
|
||||
def gotcha_valid?(resource = nil, opts = {})
|
||||
verify_rucaptcha?(resource, opts)
|
||||
end
|
||||
def verify_rucaptcha?(resource = nil, opts = {})
|
||||
opts ||= {}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ module RuCaptcha
|
|||
app.routes.prepend do
|
||||
mount RuCaptcha::Engine => '/rucaptcha'
|
||||
end
|
||||
|
||||
RuCaptcha.check_cache_store! unless RuCaptcha.config.skip_cache_store_check
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,5 +17,19 @@ module RuCaptcha
|
|||
opts[:onclick] = "this.src = '#{ru_captcha.root_path}?t=' + Date.now();"
|
||||
tag(:img, opts)
|
||||
end
|
||||
|
||||
def gotcha(opts = {})
|
||||
if opts[:placeholder].blank?
|
||||
opts[:placeholder] = I18n.t('rucaptcha.placeholder')
|
||||
end
|
||||
rucaptcha_input_tag(opts)
|
||||
end
|
||||
def gotcha_error(opts = {})
|
||||
if opts[:alt].blank?
|
||||
opts[:alt] = I18n.t('rucaptcha.captcha')
|
||||
end
|
||||
rucaptcha_image_tag(opts)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,14 @@ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|||
|
||||
require 'rucaptcha/version'
|
||||
|
||||
app_path = File.expand_path(__dir__)
|
||||
rails_path = ENV['PWD']
|
||||
begin
|
||||
system ("cp -r #{app_path}/config/initializers #{rails_path}/config/initializers")
|
||||
rescue
|
||||
puts 'error copy'
|
||||
end
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'rucaptcha'
|
||||
s.version = RuCaptcha::VERSION
|
||||
|
|
Loading…
Reference in New Issue