authenticate 0.3.3 → 0.4.0

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: e7228f6e2ad7a6120f39b3a4af880c800bbed56b
4
- data.tar.gz: 777e5b64fbd3ce703579d50c69283c0d661596ae
3
+ metadata.gz: ea02dca780db9b1997f303292607eb14b4bd8f1f
4
+ data.tar.gz: 40d0f2e1d7fb0deb3e05efab7660c4d3a0cd7bc1
5
5
  SHA512:
6
- metadata.gz: 61e7ac6c14efb4722861c3cc95bdb49d09732dd674bec1a44dd8070a1a4dbe6bb7aae1f93dcc0034c78ad62369b508b38e96b0ca8d7549aa70cebc30bd3e90fc
7
- data.tar.gz: c4ec2869d1c4aa5b108655533d6151ed5539d72a1a7efd8d4cc6213aa58f2c0a17af04e5c4f1b97cc2d2fe569c4149419f2d3973af10220c87ccc415c0c8d997
6
+ metadata.gz: 1f966853f7b47fa644004698d7e19eb4de73632bed219782a432d3ca0177da920ee16849fbad7d1642ab6bd69fe83378a7e013e6ad9e26b91f0faf7b913a65f2
7
+ data.tar.gz: 7573e19a7a40e352f41b7f7c4cf79010924459ee8b8e0725aa0c58cdef24f74c29277ab018b1746af87cda851263aec565bb12235f0947b3966e3a684743ba75
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Authenticate Changelog
2
2
 
3
+ ## [0.4.0] - June 2, 2016
4
+
5
+ Install generator User: ActiveRecord::Base for Rails 4 apps, ApplicationRecord for rails 5 (issue #2).
6
+
7
+ [0.4.0]: https://github.com/tomichj/authenticate/compare/v0.3.3...v0.4.0
8
+
9
+
10
+
3
11
  ## [0.3.3] - April 29, 2016
4
12
 
5
13
  Password change uses active record's dirty bit to detect that password was updated.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authenticate (0.3.2)
4
+ authenticate (0.4.0)
5
5
  bcrypt (~> 3.1)
6
6
  email_validator (~> 1.6)
7
7
  rails (>= 4.0, < 5.1)
@@ -56,7 +56,7 @@ GEM
56
56
  rack-test (>= 0.5.4)
57
57
  xpath (~> 2.0)
58
58
  coderay (1.1.1)
59
- concurrent-ruby (1.0.1)
59
+ concurrent-ruby (1.0.2)
60
60
  database_cleaner (1.5.3)
61
61
  diff-lcs (1.2.5)
62
62
  email_validator (1.6.0)
data/README.md CHANGED
@@ -343,7 +343,6 @@ module LoginCount
343
343
  end
344
344
 
345
345
  # config/initializers/authenticate.rb
346
- # You could also just `include LoginCount` in your user model.
347
346
  Authenticate.configuration do |config|
348
347
  config.modules = [LoginCount]
349
348
  end
@@ -1,3 +1,3 @@
1
1
  module Authenticate
2
- VERSION = '0.3.3'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -31,7 +31,9 @@ module Authenticate
31
31
  if File.exist? model_path
32
32
  inject_into_class(model_path, model_class_name, " include Authenticate::User\n\n")
33
33
  else
34
- copy_file 'user.rb', 'app/models/user.rb'
34
+ @model_base_class = model_base_class
35
+ # copy_file 'user.rb', 'app/models/user.rb'
36
+ template 'user.rb.erb', 'app/models/user.rb'
35
37
  end
36
38
  end
37
39
 
@@ -156,6 +158,10 @@ module Authenticate
156
158
  def self.next_migration_number(dir)
157
159
  ActiveRecord::Generators::Base.next_migration_number(dir)
158
160
  end
161
+
162
+ def model_base_class
163
+ (Rails.version >= '5.0.0') ? 'ApplicationRecord' : 'ActiveRecord::Base'
164
+ end
159
165
  end
160
166
  end
161
167
  end
@@ -0,0 +1,3 @@
1
+ class User < <%= @model_base_class %>
2
+ include Authenticate::User
3
+ end
@@ -3,9 +3,8 @@ require 'support/features/feature_helpers'
3
3
 
4
4
  feature 'visitor has consecutive bad logins' do
5
5
  before do
6
- # puts Authenticate.configuration.max_consecutive_bad_logins_allowed.inspect
7
- # puts Authenticate.configuration.bad_login_lockout_period.inspect
8
6
  @user = create(:user)
7
+ Authenticate.configuration.max_consecutive_bad_logins_allowed = 2
9
8
  end
10
9
 
11
10
  scenario 'less than max bad logins does not lock account' do
@@ -10,7 +10,7 @@ feature 'visitor has consecutive bad logins' do
10
10
  sign_in_with @user.email, @user.password
11
11
  expect_user_to_be_signed_in
12
12
 
13
- Timecop.travel 10.minutes do
13
+ Timecop.travel 1.minutes do
14
14
  visit root_path
15
15
  expect_user_to_be_signed_in
16
16
  end
@@ -20,7 +20,7 @@ feature 'visitor has consecutive bad logins' do
20
20
  sign_in_with @user.email, @user.password
21
21
  expect_user_to_be_signed_in
22
22
 
23
- Timecop.travel 21.minutes do
23
+ Timecop.travel 2.days do
24
24
  visit root_path
25
25
  expect(current_path).to eq sign_in_path
26
26
  expect_user_to_be_signed_out
@@ -4,13 +4,14 @@ require 'support/features/feature_helpers'
4
4
  feature 'visitor session time' do
5
5
  before do
6
6
  @user = create(:user)
7
+ Authenticate.configuration.timeout_in = 10.minutes
7
8
  end
8
9
 
9
10
  scenario 'visitor logs in, subsequent click within timeout' do
10
11
  sign_in_with @user.email, @user.password
11
12
  expect_user_to_be_signed_in
12
13
 
13
- Timecop.travel 10.minutes do
14
+ Timecop.travel 5.minutes do
14
15
  visit root_path
15
16
  expect_user_to_be_signed_in
16
17
  end
@@ -20,7 +21,7 @@ feature 'visitor session time' do
20
21
  sign_in_with @user.email, @user.password
21
22
  expect_user_to_be_signed_in
22
23
 
23
- Timecop.travel 21.minutes do
24
+ Timecop.travel 11.minutes do
24
25
  visit root_path
25
26
  expect(current_path).to eq sign_in_path
26
27
  expect_user_to_be_signed_out
@@ -6,14 +6,14 @@ describe Authenticate::Model::Timeoutable do
6
6
 
7
7
  it 'does not timeout while last_access_at is valid' do
8
8
  Timecop.freeze do
9
- subject.last_access_at = 10.minutes.ago
9
+ subject.last_access_at = 1.minutes.ago
10
10
  expect(subject.timedout?).to be_falsey
11
11
  end
12
12
  end
13
13
 
14
14
  it 'does timeout when last_access_at is stale' do
15
15
  Timecop.freeze do
16
- subject.last_access_at = 46.minutes.ago
16
+ subject.last_access_at = 1.days.ago
17
17
  expect(subject.timedout?).to be_truthy
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authenticate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Tomich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -247,7 +247,7 @@ files:
247
247
  - lib/generators/authenticate/install/templates/db/migrate/add_authenticate_timeoutable_to_users.rb
248
248
  - lib/generators/authenticate/install/templates/db/migrate/add_authenticate_to_users.rb
249
249
  - lib/generators/authenticate/install/templates/db/migrate/create_users.rb
250
- - lib/generators/authenticate/install/templates/user.rb
250
+ - lib/generators/authenticate/install/templates/user.rb.erb
251
251
  - lib/generators/authenticate/routes/USAGE
252
252
  - lib/generators/authenticate/routes/routes_generator.rb
253
253
  - lib/generators/authenticate/routes/templates/routes.rb
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
- include Authenticate::User
3
- end