signinable 2.0.8 → 2.0.9

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: c6aedbf478d474ba1c4eaea564eb5923f447d014
4
- data.tar.gz: 1e679b63fc9ffc805c4ed762db8d56accf7d0bd5
3
+ metadata.gz: dfd2f8cb93874c2f44d45af37cb5bd4290a6ee97
4
+ data.tar.gz: 2f351adfbffad55c6cb969da80e995876ebbf3e7
5
5
  SHA512:
6
- metadata.gz: 7da61b67ae30e1a09e5f023b30b7a757485e5ed72fa97b6eb2b0ada32986e75efa4c822a173dc796b47fbd9d27cc4410ece7fcf7638402515c86bf0d4fd478a3
7
- data.tar.gz: 758f8ac930b49ade4264a7d9084d62104a1b700a80ba7e681c0c17a330aa6f9255fd467840a77b3fe31a2b45f2decb82307f6214093d9b8b004e8711a1380878
6
+ metadata.gz: 76d30b26ad8ff5f4c48cfc5a62b83ab5d671ca466e577ede1eee46cb834e60370146cd7f86a5502aca92c00f67e4fb9ff4496d9a57b18536db5fac3a8638bd1e
7
+ data.tar.gz: ecc32963b5478ff9f610d0bbd8b8448787eeb070ac0d9232c39fb7f9f1d65ca3f44ecd8c859aa757685a2fe59ee6b4aef86cb11667aa4eac9707b05208e514c3
data/app/models/signin.rb CHANGED
@@ -19,4 +19,9 @@ class Signin < ActiveRecord::Base
19
19
  def expired?
20
20
  expiration_time && expiration_time <= Time.zone.now
21
21
  end
22
+
23
+ if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "mysql"
24
+ serialize :custom_data
25
+ end
26
+
22
27
  end
@@ -0,0 +1,13 @@
1
+ migration_kls = Rails::VERSION::MAJOR > 4 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
2
+
3
+ class AddCustomDataToSigins < migration_kls
4
+ def change
5
+
6
+ if ActiveRecord::Base.connection.instance_values["config"][:adapter] == "postgresql"
7
+ add_column :signins, :custom_data, :jsonb, null:false, default: {}
8
+ else
9
+ add_column :signins, :custom_data, :string, null:false, default: {}.to_json
10
+ end
11
+
12
+ end
13
+ end
@@ -59,12 +59,12 @@ module Signinable
59
59
  end
60
60
  end
61
61
 
62
- def signin(ip, user_agent, referer, permanent = false)
62
+ def signin(ip, user_agent, referer, permanent = false, custom_data = {})
63
63
  if self.class.signin_expiration.respond_to?(:call)
64
64
  self.class.signin_expiration = self.class.signin_expiration.call(self)
65
65
  end
66
66
  expiration_time = (self.class.signin_expiration == 0 || permanent) ? nil : (Time.zone.now + self.class.signin_expiration)
67
- Signin.create!(signinable: self, ip: ip, referer: referer, user_agent: user_agent, expiration_time: expiration_time).token
67
+ Signin.create!(custom_data: custom_data, signinable: self, ip: ip, referer: referer, user_agent: user_agent, expiration_time: expiration_time).token
68
68
  end
69
69
 
70
70
  def signout(token, ip, user_agent, skip_restrictions=[])
@@ -81,6 +81,7 @@ module Signinable
81
81
  def last_signin
82
82
  signins.last unless signins.empty?
83
83
  end
84
+
84
85
  end
85
86
  end
86
87
 
@@ -1,3 +1,3 @@
1
1
  module Signinable
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.9"
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.8
4
+ version: 2.0.9
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-11-09 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -93,6 +93,7 @@ files:
93
93
  - app/models/signin.rb
94
94
  - config/routes.rb
95
95
  - db/migrate/20140103165607_create_signins.rb
96
+ - db/migrate/20180530131006_add_custom_data_to_sigins.rb
96
97
  - lib/signinable.rb
97
98
  - lib/signinable/engine.rb
98
99
  - lib/signinable/model_additions.rb
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  version: '0'
154
155
  requirements: []
155
156
  rubyforge_project:
156
- rubygems_version: 2.4.8
157
+ rubygems_version: 2.5.1
157
158
  signing_key:
158
159
  specification_version: 4
159
160
  summary: Token based signin