signinable 2.0.3 → 2.0.4

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: ed8b7004a61e8356629c4043414ac984c2c220ad
4
- data.tar.gz: 3c04410f2c4690f100c75990210f9adb0ff16fae
3
+ metadata.gz: f7f444bdf0cb1a270d31e004760a723d8e8ba48e
4
+ data.tar.gz: b40c23efac320454d30e10362c80d45bfcd22ca6
5
5
  SHA512:
6
- metadata.gz: 99741bb1307f71aabad86d3b259917501d7db9f48c0d21c2375968bd178c17b6df4e52ce7580bb1e3b5175d84178d3454e7408ceb932ee17890c04f3d6a07a93
7
- data.tar.gz: e2f1997057b4171c04482822bfa86fa1ceb6deb18924caab04da6eef02379b4ea64b15593323a3c978b63e4aaace9c954a5de6d4ecac865d4f6d9b867cc880cb
6
+ metadata.gz: 1a106fb31f69898db7a42b7ea6803171cd91f3400c9c08a7265089442d5aa8f32ec4ef8383a1a61ee66f5b0f97edca80eff6c61a1a3b9320e5a168fed72e5c23
7
+ data.tar.gz: 932903248820c31efa56fba59770723a8db7faa5c4a648a2860a07a0093815aa499043a1d2409ab7918cdf2842829233f8ecd646d7f11d36799c7c9d92e5dee3
@@ -7,9 +7,9 @@ module Signinable
7
7
  cattr_accessor :signin_expiration
8
8
  cattr_accessor :signin_simultaneous
9
9
  cattr_accessor :signin_restrictions
10
- self.signin_expiration = options[:expiration] || 2.hours
11
- self.signin_simultaneous = options[:simultaneous] || true
12
- self.signin_restrictions = (options[:restrictions] && options[:restrictions].is_a?(Array)) ? options[:restrictions] : []
10
+ self.signin_expiration = options.fetch(:expiration, 2.hours)
11
+ self.signin_simultaneous = options.fetch(:simultaneous, true)
12
+ self.signin_restrictions = options.fetch(:restrictions, []).is_a?(Array) ? options[:restrictions] : []
13
13
 
14
14
  has_many :signins, as: :signinable, dependent: :destroy
15
15
  end
@@ -29,7 +29,7 @@ module Signinable
29
29
  end
30
30
 
31
31
  return nil unless self.check_signin_permission(signin, ip, user_agent)
32
- signin.update!(expiration_time: (Time.zone.now + self.signin_expiration)) unless self.signin_expiration == 0
32
+ signin.update!(expiration_time: (Time.zone.now + self.signin_expiration)) unless signin.expiration_time.nil? || self.signin_expiration == 0
33
33
  signin.signinable
34
34
  end
35
35
  end
@@ -50,11 +50,11 @@ module Signinable
50
50
  end
51
51
  end
52
52
 
53
- def signin(ip, user_agent, referer)
53
+ def signin(ip, user_agent, referer, permanent = false)
54
54
  if self.class.signin_expiration.respond_to?(:call)
55
55
  self.class.signin_expiration = self.class.signin_expiration.call(self)
56
56
  end
57
- expiration_time = self.class.signin_expiration == 0 ? nil : (Time.zone.now + self.class.signin_expiration)
57
+ expiration_time = (self.class.signin_expiration == 0 || permanent) ? nil : (Time.zone.now + self.class.signin_expiration)
58
58
  Signin.create!(signinable: self, ip: ip, referer: referer, user_agent: user_agent, expiration_time: expiration_time).token
59
59
  end
60
60
 
@@ -1,3 +1,3 @@
1
1
  module Signinable
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
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.3
4
+ version: 2.0.4
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-04-11 00:00:00.000000000 Z
11
+ date: 2017-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails