devise_token_auth 0.2.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise_token_auth might be problematic. Click here for more details.

Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/Rakefile +9 -4
  4. data/app/controllers/devise_token_auth/application_controller.rb +5 -7
  5. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +2 -2
  6. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +18 -10
  7. data/app/controllers/devise_token_auth/confirmations_controller.rb +2 -2
  8. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +17 -23
  9. data/app/controllers/devise_token_auth/passwords_controller.rb +23 -27
  10. data/app/controllers/devise_token_auth/registrations_controller.rb +17 -15
  11. data/app/controllers/devise_token_auth/sessions_controller.rb +8 -12
  12. data/app/controllers/devise_token_auth/token_validations_controller.rb +3 -3
  13. data/app/controllers/devise_token_auth/unlocks_controller.rb +10 -12
  14. data/app/models/devise_token_auth/concerns/user.rb +27 -36
  15. data/config/initializers/devise.rb +1 -1
  16. data/lib/devise_token_auth.rb +6 -6
  17. data/lib/devise_token_auth/controllers/helpers.rb +14 -4
  18. data/lib/devise_token_auth/engine.rb +11 -13
  19. data/lib/devise_token_auth/errors.rb +1 -1
  20. data/lib/devise_token_auth/rails/routes.rb +29 -29
  21. data/lib/devise_token_auth/url.rb +6 -4
  22. data/lib/devise_token_auth/version.rb +1 -1
  23. data/lib/generators/devise_token_auth/install_generator.rb +52 -39
  24. data/lib/generators/devise_token_auth/install_views_generator.rb +5 -5
  25. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +1 -1
  26. data/lib/generators/devise_token_auth/templates/{user.rb → user.rb.erb} +0 -0
  27. data/test/controllers/custom/custom_confirmations_controller_test.rb +3 -1
  28. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +2 -0
  29. data/test/controllers/custom/custom_passwords_controller_test.rb +4 -2
  30. data/test/controllers/custom/custom_registrations_controller_test.rb +6 -8
  31. data/test/controllers/custom/custom_sessions_controller_test.rb +5 -5
  32. data/test/controllers/custom/custom_token_validations_controller_test.rb +3 -3
  33. data/test/controllers/demo_group_controller_test.rb +2 -6
  34. data/test/controllers/demo_mang_controller_test.rb +2 -5
  35. data/test/controllers/demo_user_controller_test.rb +8 -17
  36. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +2 -2
  37. data/test/controllers/devise_token_auth/passwords_controller_test.rb +13 -9
  38. data/test/controllers/devise_token_auth/registrations_controller_test.rb +8 -8
  39. data/test/controllers/devise_token_auth/sessions_controller_test.rb +22 -33
  40. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +2 -6
  41. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +1 -1
  42. data/test/controllers/overrides/confirmations_controller_test.rb +3 -1
  43. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +3 -1
  44. data/test/controllers/overrides/passwords_controller_test.rb +25 -29
  45. data/test/controllers/overrides/registrations_controller_test.rb +4 -2
  46. data/test/controllers/overrides/sessions_controller_test.rb +4 -4
  47. data/test/controllers/overrides/token_validations_controller_test.rb +3 -3
  48. data/test/dummy/app/controllers/custom/confirmations_controller.rb +0 -2
  49. data/test/dummy/app/controllers/custom/passwords_controller.rb +1 -4
  50. data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -2
  51. data/test/dummy/app/controllers/custom/sessions_controller.rb +1 -3
  52. data/test/dummy/app/controllers/custom/token_validations_controller.rb +1 -3
  53. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -3
  54. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +3 -3
  55. data/test/dummy/app/controllers/overrides/passwords_controller.rb +5 -5
  56. data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
  57. data/test/dummy/app/controllers/overrides/sessions_controller.rb +8 -10
  58. data/test/dummy/app/controllers/overrides/token_validations_controller.rb +3 -5
  59. data/test/dummy/app/helpers/application_helper.rb +1027 -1036
  60. data/test/dummy/app/models/scoped_user.rb +2 -2
  61. data/test/dummy/app/models/unregisterable_user.rb +2 -2
  62. data/test/dummy/app/models/user.rb +1 -1
  63. data/test/dummy/config.ru +5 -3
  64. data/test/dummy/config/application.rb +2 -2
  65. data/test/dummy/config/boot.rb +2 -2
  66. data/test/dummy/config/environment.rb +1 -1
  67. data/test/dummy/config/environments/development.rb +3 -3
  68. data/test/dummy/config/environments/test.rb +1 -1
  69. data/test/dummy/config/initializers/omniauth.rb +2 -2
  70. data/test/dummy/config/routes.rb +10 -29
  71. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +8 -8
  72. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +7 -7
  73. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +4 -4
  74. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +7 -7
  75. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +7 -7
  76. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +7 -7
  77. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +6 -6
  78. data/test/dummy/db/schema.rb +2 -60
  79. data/test/factories/users.rb +40 -0
  80. data/test/lib/devise_token_auth/url_test.rb +6 -6
  81. data/test/lib/generators/devise_token_auth/install_generator_test.rb +22 -14
  82. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +30 -22
  83. data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +1 -1
  84. data/test/models/user_test.rb +15 -46
  85. data/test/support/controllers/routes.rb +43 -0
  86. data/test/test_helper.rb +12 -12
  87. metadata +8 -14
  88. data/test/dummy/app/models/evil_user.rb +0 -5
  89. data/test/dummy/app/models/nice_user.rb +0 -9
  90. data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +0 -66
  91. data/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +0 -63
  92. data/test/integration/navigation_test.rb +0 -12
@@ -0,0 +1,43 @@
1
+ class Module
2
+ include Minitest::Spec::DSL
3
+ end
4
+
5
+ module ControllerRoutesAfterBlock
6
+ after do
7
+ Rails.application.reload_routes!
8
+ end
9
+ end
10
+
11
+ module CustomControllersRoutes
12
+ include ControllerRoutesAfterBlock
13
+
14
+ before do
15
+ Rails.application.routes.draw do
16
+ mount_devise_token_auth_for 'User', at: 'nice_user_auth', controllers: {
17
+ registrations: 'custom/registrations',
18
+ confirmations: 'custom/confirmations',
19
+ passwords: 'custom/passwords',
20
+ sessions: 'custom/sessions',
21
+ token_validations: 'custom/token_validations',
22
+ omniauth_callbacks: 'custom/omniauth_callbacks'
23
+ }
24
+ end
25
+ end
26
+ end
27
+
28
+ module OverridesControllersRoutes
29
+ include ControllerRoutesAfterBlock
30
+
31
+ before do
32
+ Rails.application.routes.draw do
33
+ mount_devise_token_auth_for 'User', at: 'evil_user_auth', controllers: {
34
+ confirmations: 'overrides/confirmations',
35
+ passwords: 'overrides/passwords',
36
+ omniauth_callbacks: 'overrides/omniauth_callbacks',
37
+ registrations: 'overrides/registrations',
38
+ sessions: 'overrides/sessions',
39
+ token_validations: 'overrides/token_validations'
40
+ }
41
+ end
42
+ end
43
+ end
@@ -1,18 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'simplecov'
4
-
5
- SimpleCov.start 'rails'
4
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
5
+ SimpleCov.start 'rails' do
6
+ add_filter ['.bundle', 'test', 'config']
7
+ end
6
8
 
7
9
  ENV['RAILS_ENV'] = 'test'
8
10
 
9
- require File.expand_path('../dummy/config/environment', __FILE__)
11
+ require File.expand_path('dummy/config/environment', __dir__)
10
12
  require 'rails/test_help'
11
13
  require 'minitest/rails'
12
14
  require 'mocha/minitest'
13
15
 
14
- ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
15
- ActionDispatch::IntegrationTest.fixture_path = File.expand_path('../fixtures', __FILE__)
16
+ FactoryBot.definition_file_paths = [File.expand_path('factories', __dir__)]
17
+ FactoryBot.find_definitions
18
+
19
+ Dir[File.join(__dir__, 'support/**', '*.rb')].each { |file| require file }
16
20
 
17
21
  # I hate the default reporter. Use ProgressReporter instead.
18
22
  Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
@@ -24,13 +28,9 @@ class ActionDispatch::IntegrationTest
24
28
  end
25
29
 
26
30
  class ActiveSupport::TestCase
27
- ActiveRecord::Migration.check_pending!
31
+ include FactoryBot::Syntax::Methods
28
32
 
29
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
30
- #
31
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
32
- # -- they do not yet inherit this setting
33
- fixtures :all
33
+ ActiveRecord::Migration.check_pending!
34
34
 
35
35
  # Add more helper methods to be used by all tests here...
36
36
 
@@ -51,7 +51,7 @@ class ActiveSupport::TestCase
51
51
  # Suppress OmniAuth logger output
52
52
  def silence_omniauth
53
53
  previous_logger = OmniAuth.config.logger
54
- OmniAuth.config.logger = Logger.new("/dev/null")
54
+ OmniAuth.config.logger = Logger.new('/dev/null')
55
55
  yield
56
56
  ensure
57
57
  OmniAuth.config.logger = previous_logger
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_token_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lynn Hurley
@@ -161,7 +161,7 @@ files:
161
161
  - lib/generators/devise_token_auth/install_views_generator.rb
162
162
  - lib/generators/devise_token_auth/templates/devise_token_auth.rb
163
163
  - lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb
164
- - lib/generators/devise_token_auth/templates/user.rb
164
+ - lib/generators/devise_token_auth/templates/user.rb.erb
165
165
  - lib/tasks/devise_token_auth_tasks.rake
166
166
  - test/controllers/custom/custom_confirmations_controller_test.rb
167
167
  - test/controllers/custom/custom_omniauth_callbacks_controller_test.rb
@@ -204,10 +204,8 @@ files:
204
204
  - test/dummy/app/controllers/overrides/sessions_controller.rb
205
205
  - test/dummy/app/controllers/overrides/token_validations_controller.rb
206
206
  - test/dummy/app/helpers/application_helper.rb
207
- - test/dummy/app/models/evil_user.rb
208
207
  - test/dummy/app/models/lockable_user.rb
209
208
  - test/dummy/app/models/mang.rb
210
- - test/dummy/app/models/nice_user.rb
211
209
  - test/dummy/app/models/only_email_user.rb
212
210
  - test/dummy/app/models/scoped_user.rb
213
211
  - test/dummy/app/models/unconfirmable_user.rb
@@ -240,10 +238,8 @@ files:
240
238
  - test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb
241
239
  - test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb
242
240
  - test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb
243
- - test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb
244
241
  - test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb
245
242
  - test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb
246
- - test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb
247
243
  - test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb
248
244
  - test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
249
245
  - test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb
@@ -252,13 +248,14 @@ files:
252
248
  - test/dummy/tmp/generators/app/models/user.rb
253
249
  - test/dummy/tmp/generators/config/initializers/devise_token_auth.rb
254
250
  - test/dummy/tmp/generators/db/migrate/20180805205504_devise_token_auth_create_users.rb
255
- - test/integration/navigation_test.rb
251
+ - test/factories/users.rb
256
252
  - test/lib/devise_token_auth/url_test.rb
257
253
  - test/lib/generators/devise_token_auth/install_generator_test.rb
258
254
  - test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb
259
255
  - test/lib/generators/devise_token_auth/install_views_generator_test.rb
260
256
  - test/models/only_email_user_test.rb
261
257
  - test/models/user_test.rb
258
+ - test/support/controllers/routes.rb
262
259
  - test/test_helper.rb
263
260
  homepage: http://github.com/lynndylanhurley/devise_token_auth
264
261
  licenses:
@@ -275,9 +272,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
272
  version: '0'
276
273
  required_rubygems_version: !ruby/object:Gem::Requirement
277
274
  requirements:
278
- - - ">="
275
+ - - ">"
279
276
  - !ruby/object:Gem::Version
280
- version: '0'
277
+ version: 1.3.1
281
278
  requirements: []
282
279
  rubyforge_project:
283
280
  rubygems_version: 2.6.14.1
@@ -285,10 +282,8 @@ signing_key:
285
282
  specification_version: 4
286
283
  summary: Token based authentication for rails. Uses Devise + OmniAuth.
287
284
  test_files:
288
- - test/dummy/app/models/nice_user.rb
289
285
  - test/dummy/app/models/only_email_user.rb
290
286
  - test/dummy/app/models/scoped_user.rb
291
- - test/dummy/app/models/evil_user.rb
292
287
  - test/dummy/app/models/mang.rb
293
288
  - test/dummy/app/models/unregisterable_user.rb
294
289
  - test/dummy/app/models/lockable_user.rb
@@ -343,18 +338,17 @@ test_files:
343
338
  - test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb
344
339
  - test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb
345
340
  - test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb
346
- - test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb
347
341
  - test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb
348
342
  - test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb
349
343
  - test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb
350
- - test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb
351
344
  - test/dummy/tmp/generators/app/models/user.rb
352
345
  - test/dummy/tmp/generators/config/initializers/devise_token_auth.rb
353
346
  - test/dummy/tmp/generators/db/migrate/20180805205504_devise_token_auth_create_users.rb
354
347
  - test/dummy/README.rdoc
355
- - test/integration/navigation_test.rb
356
348
  - test/models/only_email_user_test.rb
357
349
  - test/models/user_test.rb
350
+ - test/support/controllers/routes.rb
351
+ - test/factories/users.rb
358
352
  - test/lib/devise_token_auth/url_test.rb
359
353
  - test/lib/generators/devise_token_auth/install_generator_test.rb
360
354
  - test/lib/generators/devise_token_auth/install_views_generator_test.rb
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class EvilUser < ActiveRecord::Base
4
- include DeviseTokenAuth::Concerns::User
5
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NiceUser < ActiveRecord::Base
4
- # Include default devise modules.
5
- devise :database_authenticatable, :registerable,
6
- :recoverable, :rememberable, :trackable, :validatable,
7
- :confirmable, :omniauthable
8
- include DeviseTokenAuth::Concerns::User
9
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- include MigrationDatabaseHelper
4
-
5
- class DeviseTokenAuthCreateEvilUsers < ActiveRecord::Migration[4.2]
6
- def change
7
- create_table(:evil_users) do |t|
8
- ## Database authenticatable
9
- t.string :email
10
- t.string :encrypted_password, :null => false, :default => ""
11
-
12
- ## Recoverable
13
- t.string :reset_password_token
14
- t.datetime :reset_password_sent_at
15
- t.boolean :allow_password_change, :default => false
16
-
17
- ## Rememberable
18
- t.datetime :remember_created_at
19
-
20
- ## Trackable
21
- t.integer :sign_in_count, :default => 0, :null => false
22
- t.datetime :current_sign_in_at
23
- t.datetime :last_sign_in_at
24
- t.string :current_sign_in_ip
25
- t.string :last_sign_in_ip
26
-
27
- ## Confirmable
28
- t.string :confirmation_token
29
- t.datetime :confirmed_at
30
- t.datetime :confirmation_sent_at
31
- t.string :unconfirmed_email # Only if using reconfirmable
32
-
33
- ## Lockable
34
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
35
- # t.string :unlock_token # Only if unlock strategy is :email or :both
36
- # t.datetime :locked_at
37
-
38
- ## User Info
39
- t.string :name
40
- t.string :nickname
41
- t.string :image
42
-
43
- ## unique oauth id
44
- t.string :provider
45
- t.string :uid, :null => false, :default => ""
46
-
47
- ## Tokens
48
- if json_supported_database?
49
- t.json :tokens
50
- else
51
- t.text :tokens
52
- end
53
-
54
- ## etc.
55
- t.string :favorite_color
56
-
57
- t.timestamps
58
- end
59
-
60
- add_index :evil_users, :email
61
- add_index :evil_users, [:uid, :provider], :unique => true
62
- add_index :evil_users, :reset_password_token, :unique => true
63
- add_index :evil_users, :confirmation_token, :unique => true
64
- # add_index :evil_users, :unlock_token, :unique => true
65
- end
66
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- include MigrationDatabaseHelper
4
-
5
- class DeviseTokenAuthCreateNiceUsers < ActiveRecord::Migration[4.2]
6
- def change
7
- create_table(:nice_users) do |t|
8
- ## Required
9
- t.string :provider, :null => false
10
- t.string :uid, :null => false, :default => ""
11
-
12
- ## Database authenticatable
13
- t.string :encrypted_password, :null => false, :default => ""
14
-
15
- ## Recoverable
16
- t.string :reset_password_token
17
- t.datetime :reset_password_sent_at
18
- t.boolean :allow_password_change, :default => false
19
-
20
- ## Rememberable
21
- t.datetime :remember_created_at
22
-
23
- ## Trackable
24
- t.integer :sign_in_count, :default => 0, :null => false
25
- t.datetime :current_sign_in_at
26
- t.datetime :last_sign_in_at
27
- t.string :current_sign_in_ip
28
- t.string :last_sign_in_ip
29
-
30
- ## Confirmable
31
- t.string :confirmation_token
32
- t.datetime :confirmed_at
33
- t.datetime :confirmation_sent_at
34
- t.string :unconfirmed_email # Only if using reconfirmable
35
-
36
- ## Lockable
37
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
38
- # t.string :unlock_token # Only if unlock strategy is :email or :both
39
- # t.datetime :locked_at
40
-
41
- ## User Info
42
- t.string :name
43
- t.string :nickname
44
- t.string :image
45
- t.string :email
46
-
47
- ## Tokens
48
- if json_supported_database?
49
- t.json :tokens
50
- else
51
- t.text :tokens
52
- end
53
-
54
- t.timestamps
55
- end
56
-
57
- add_index :nice_users, :email
58
- add_index :nice_users, [:uid, :provider], :unique => true
59
- add_index :nice_users, :reset_password_token, :unique => true
60
- # add_index :nice_users, :confirmation_token, :unique => true
61
- # add_index :nice_users, :unlock_token, :unique => true
62
- end
63
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class NavigationTest < ActionDispatch::IntegrationTest
6
- fixtures :all
7
-
8
- # test "the truth" do
9
- # assert true
10
- # end
11
- end
12
-