Skip to content

Commit

Permalink
add capcha gem
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn committed Sep 10, 2024
1 parent ec2eec4 commit 4e1c9f3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ gem 'mina'
gem 'lograge'
# for listening to file modifications
gem 'listen'
# capcha
gem 'rucaptcha'
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rb_sys (0.9.102)
redcarpet (3.6.0)
regexp_parser (2.9.2)
request_store (1.7.0)
Expand Down Expand Up @@ -322,6 +323,9 @@ GEM
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
rucaptcha (3.2.3)
railties (>= 3.2)
rb_sys (>= 0.9.86)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
Expand Down Expand Up @@ -436,6 +440,7 @@ DEPENDENCIES
rubocop-factory_bot
rubocop-rails
rubocop-rspec
rucaptcha
sass-rails
selectize-rails
sentry-rails
Expand Down
31 changes: 31 additions & 0 deletions config/initializers/rucaptcha.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
RuCaptcha.configure do
# 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 = :mem_cache_store

# If you wants disable `cache_store` check warning, you can do it, default: false
# 如果想要 disable cache_store 的 warning,就设置为 true,default false
# self.skip_cache_store_check = true

# Chars length, default: 5, allows: [3 - 7]
# self.length = 5

# Enable or disable Strikethrough, default: true
# self.line = true

# Enable or disable noise, default: false
# self.noise = false

# Set the image format, default: png, allows: [jpeg, png, webp]
# self.format = 'png'

# Custom mount path, default: '/rucaptcha'
# self.mount_path = '/rucaptcha'
end

0 comments on commit 4e1c9f3

Please sign in to comment.