signinable 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7f444bdf0cb1a270d31e004760a723d8e8ba48e
4
- data.tar.gz: b40c23efac320454d30e10362c80d45bfcd22ca6
3
+ metadata.gz: 55794149ad1cc0c4a7be9a08d2cefbb0e1d10d61
4
+ data.tar.gz: e59d8ae956f9d4833c58ffb674358b1e4d4cba79
5
5
  SHA512:
6
- metadata.gz: 1a106fb31f69898db7a42b7ea6803171cd91f3400c9c08a7265089442d5aa8f32ec4ef8383a1a61ee66f5b0f97edca80eff6c61a1a3b9320e5a168fed72e5c23
7
- data.tar.gz: 932903248820c31efa56fba59770723a8db7faa5c4a648a2860a07a0093815aa499043a1d2409ab7918cdf2842829233f8ecd646d7f11d36799c7c9d92e5dee3
6
+ metadata.gz: 8331f8045d7b3bbfeac9bc0c52239b0db9ee21e23a3616308dbc70a21bc6179e13b7894575c69fa55c8c119c302b37fec739d93badf0c74be57748d79404d0a6
7
+ data.tar.gz: 598d52c18fe092f3e59f6e781d9c34e9aeff4f5a81ac0825d25f616bf74c2fc929239f21f6bb9c4ab36841c69fec8d8dc3185b93c420b11ccaca0d076388c2c8
data/app/models/signin.rb CHANGED
@@ -1,10 +1,12 @@
1
+ require 'resolv'
2
+
1
3
  class Signin < ActiveRecord::Base
2
4
  belongs_to :signinable, polymorphic: true
3
5
 
4
6
  validates :token, presence: true
5
7
  validates :ip,
6
8
  presence: true,
7
- format: { with: /\A([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}\z/ }
9
+ format: { with: Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex) }
8
10
 
9
11
  before_validation on: :create do
10
12
  self.token = SecureRandom.urlsafe_base64(rand(50..100))
@@ -9,7 +9,7 @@ module Signinable
9
9
  cattr_accessor :signin_restrictions
10
10
  self.signin_expiration = options.fetch(:expiration, 2.hours)
11
11
  self.signin_simultaneous = options.fetch(:simultaneous, true)
12
- self.signin_restrictions = options.fetch(:restrictions, []).is_a?(Array) ? options[:restrictions] : []
12
+ self.signin_restrictions = options[:restrictions]
13
13
 
14
14
  has_many :signins, as: :signinable, dependent: :destroy
15
15
  end
@@ -40,7 +40,16 @@ module Signinable
40
40
 
41
41
  private
42
42
  def signin_permitted?(signin, ip, user_agent)
43
- self.signin_restrictions.each do |field|
43
+ restriction_fields = case
44
+ when self.signin_restrictions.respond_to?(:call)
45
+ self.signin_restrictions.call(signin.signinable)
46
+ when self.signin_restrictions.is_a?(Array)
47
+ self.signin_restrictions
48
+ else
49
+ []
50
+ end
51
+
52
+ restriction_fields.each do |field|
44
53
  if(local_variables.include?(field.to_sym) && signin.respond_to?("#{field}"))
45
54
  return false unless signin.send("#{field}") == eval("#{field}")
46
55
  end
@@ -1,3 +1,3 @@
1
1
  module Signinable
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.6"
3
3
  end
Binary file
@@ -0,0 +1,5 @@
1
+  (5.9ms) SELECT sqlite_version(*)
2
+  (2.2ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
3
+  (0.9ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
4
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
5
+ Migrating to CreateUsers (20140103165606)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signinable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Novozhenets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,6 +122,8 @@ files:
122
122
  - spec/dummy/config/routes.rb
123
123
  - spec/dummy/db/migrate/20140103165606_create_users.rb
124
124
  - spec/dummy/db/schema.rb
125
+ - spec/dummy/db/test.sqlite3
126
+ - spec/dummy/log/test.log
125
127
  - spec/dummy/public/404.html
126
128
  - spec/dummy/public/422.html
127
129
  - spec/dummy/public/500.html
@@ -179,6 +181,8 @@ test_files:
179
181
  - spec/dummy/config.ru
180
182
  - spec/dummy/db/migrate/20140103165606_create_users.rb
181
183
  - spec/dummy/db/schema.rb
184
+ - spec/dummy/db/test.sqlite3
185
+ - spec/dummy/log/test.log
182
186
  - spec/dummy/public/404.html
183
187
  - spec/dummy/public/422.html
184
188
  - spec/dummy/public/500.html