10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/generators/devise_hacker_tracker_generator.rb', line 10
def setup_hacker_tracker_configuration
devise_initializer_path = "config/initializers/devise.rb"
if File.exist?(devise_initializer_path)
old_content = File.read(devise_initializer_path)
if old_content.match(Regexp.new(/^\s# ==> Configuration for :hacker_tracker\n/))
false
else
inject_into_file(devise_initializer_path, :before => " # ==> Configuration for :confirmable\n") do
" # ==> Configuration for :hacker_tracker
# Amount of time an IP address stays blocked for
# config.ip_block_time = 5.minutes
#
# Total number of failed sign in attempts allowed per IP address before being blocked
# config.maximum_attempts_per_ip = #{Devise.maximum_attempts_per_ip}
#
# Total number accounts a single IP address is allowed to attempt before being blocked
# config.maximum_accounts_attempted = #{Devise.maximum_accounts_attempted}
#
# The name of the table storing the failed sign in attempts
config.sign_in_failures_table_name = '#{table_name}'
"
end
end
end
end
|