log_logins 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/db/migrate/20180307161400_add_additional_indexes.rb +8 -0
- data/lib/log_logins/event.rb +13 -2
- data/lib/log_logins/version.rb +1 -1
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3655e03a98292ce6a41e5b0959a1868ad68309673582e009b5cd8135dcadab
|
4
|
+
data.tar.gz: 3075213d75edd56880de2afe1e9f6439bc7b3925d84380cfa94fcaa1aa80e1d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 961d975520465a29cae7a60fd3fd1d6bde72a45fc2edfd2b27dbabb06f74431c2610fe16c1913bdc9f4964f40f877cfc8c3f063bedcf3d678d179001bb62ebf1
|
7
|
+
data.tar.gz: d834bad436326730e642f86e97009ba8e150df5a0d1844366633bdbb3ddbc9f403532f95283afc13c0dc00cefde718919f1754f2a0bc55fa9c8d689aecc8159c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/log_logins/event.rb
CHANGED
@@ -77,7 +77,7 @@ module LogLogins
|
|
77
77
|
# @return [Boolean]
|
78
78
|
def self.user_blocked?(user)
|
79
79
|
return false unless user.is_a?(ActiveRecord::Base)
|
80
|
-
last_success = self.success_or_unblock.order(:id => :desc).select(:id).first.try(:id) || 0
|
80
|
+
last_success = self.where(:user => user).success_or_unblock.order(:id => :desc).select(:id).first.try(:id) || 0
|
81
81
|
self.failed_in_block_time.where(:user => user).where("id > ?", last_success).count >= LogLogins.config.attempts_before_block
|
82
82
|
end
|
83
83
|
|
@@ -87,9 +87,20 @@ module LogLogins
|
|
87
87
|
# @return [Boolean]
|
88
88
|
def self.ip_blocked?(ip)
|
89
89
|
return false if ip.nil?
|
90
|
-
last_success = self.success_or_unblock.order(:id => :desc).select(:id).first.try(:id) || 0
|
90
|
+
last_success = self.where(:user => nil, :ip => ip.to_s).success_or_unblock.order(:id => :desc).select(:id).first.try(:id) || 0
|
91
91
|
self.failed_in_block_time.where(:user => nil, :ip => ip.to_s).where("id > ?", last_success).count >= LogLogins.config.attempts_before_block_on_ip
|
92
92
|
end
|
93
93
|
|
94
|
+
# Delete old login data
|
95
|
+
#
|
96
|
+
# @return [Integer] the number of removed items
|
97
|
+
def self.prune(max_age = 6.months)
|
98
|
+
if last_to_keep = self.where("created_at <= ?", max_age.ago).order(:created_at => :desc).first.try(:id)
|
99
|
+
self.where("id <= ?", last_to_keep).delete_all
|
100
|
+
else
|
101
|
+
0
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
94
105
|
end
|
95
106
|
end
|
data/lib/log_logins/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_logins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -59,6 +59,7 @@ extensions: []
|
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
61
|
- db/migrate/20180307100300_create_log_logins_events_table.rb
|
62
|
+
- db/migrate/20180307161400_add_additional_indexes.rb
|
62
63
|
- lib/log_logins.rb
|
63
64
|
- lib/log_logins/config.rb
|
64
65
|
- lib/log_logins/engine.rb
|
metadata.gz.sig
CHANGED
Binary file
|