devise_token_auth 0.1.43 → 0.2.0

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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -894
  3. data/Rakefile +2 -0
  4. data/app/controllers/devise_token_auth/application_controller.rb +6 -0
  5. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +2 -0
  6. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +9 -14
  7. data/app/controllers/devise_token_auth/confirmations_controller.rb +3 -1
  8. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +2 -0
  9. data/app/controllers/devise_token_auth/passwords_controller.rb +8 -14
  10. data/app/controllers/devise_token_auth/registrations_controller.rb +26 -21
  11. data/app/controllers/devise_token_auth/sessions_controller.rb +2 -0
  12. data/app/controllers/devise_token_auth/token_validations_controller.rb +2 -0
  13. data/app/controllers/devise_token_auth/unlocks_controller.rb +2 -0
  14. data/app/models/devise_token_auth/concerns/user.rb +41 -16
  15. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +2 -0
  16. data/app/validators/email_validator.rb +3 -1
  17. data/config/initializers/devise.rb +2 -0
  18. data/config/locales/da-DK.yml +1 -1
  19. data/config/locales/sv.yml +50 -0
  20. data/lib/devise_token_auth.rb +3 -0
  21. data/lib/devise_token_auth/controllers/helpers.rb +2 -0
  22. data/lib/devise_token_auth/controllers/url_helpers.rb +2 -0
  23. data/lib/devise_token_auth/engine.rb +2 -0
  24. data/lib/devise_token_auth/errors.rb +7 -0
  25. data/lib/devise_token_auth/rails/routes.rb +2 -0
  26. data/lib/devise_token_auth/url.rb +2 -0
  27. data/lib/devise_token_auth/version.rb +3 -1
  28. data/lib/generators/devise_token_auth/USAGE +1 -1
  29. data/lib/generators/devise_token_auth/install_generator.rb +7 -5
  30. data/lib/generators/devise_token_auth/install_views_generator.rb +2 -0
  31. data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +2 -0
  32. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +8 -7
  33. data/lib/generators/devise_token_auth/templates/user.rb +3 -1
  34. data/lib/tasks/devise_token_auth_tasks.rake +2 -0
  35. data/test/controllers/custom/custom_confirmations_controller_test.rb +2 -0
  36. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +2 -0
  37. data/test/controllers/custom/custom_passwords_controller_test.rb +2 -0
  38. data/test/controllers/custom/custom_registrations_controller_test.rb +11 -0
  39. data/test/controllers/custom/custom_sessions_controller_test.rb +2 -0
  40. data/test/controllers/custom/custom_token_validations_controller_test.rb +2 -0
  41. data/test/controllers/demo_group_controller_test.rb +2 -0
  42. data/test/controllers/demo_mang_controller_test.rb +4 -1
  43. data/test/controllers/demo_user_controller_test.rb +47 -10
  44. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +4 -6
  45. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +7 -4
  46. data/test/controllers/devise_token_auth/passwords_controller_test.rb +2 -0
  47. data/test/controllers/devise_token_auth/registrations_controller_test.rb +3 -1
  48. data/test/controllers/devise_token_auth/sessions_controller_test.rb +52 -0
  49. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +2 -0
  50. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +2 -0
  51. data/test/controllers/overrides/confirmations_controller_test.rb +2 -0
  52. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +2 -0
  53. data/test/controllers/overrides/passwords_controller_test.rb +2 -0
  54. data/test/controllers/overrides/registrations_controller_test.rb +31 -27
  55. data/test/controllers/overrides/sessions_controller_test.rb +2 -0
  56. data/test/controllers/overrides/token_validations_controller_test.rb +2 -0
  57. data/test/dummy/app/controllers/application_controller.rb +2 -0
  58. data/test/dummy/app/controllers/auth_origin_controller.rb +2 -0
  59. data/test/dummy/app/controllers/custom/confirmations_controller.rb +2 -0
  60. data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +2 -0
  61. data/test/dummy/app/controllers/custom/passwords_controller.rb +2 -0
  62. data/test/dummy/app/controllers/custom/registrations_controller.rb +2 -1
  63. data/test/dummy/app/controllers/custom/sessions_controller.rb +2 -0
  64. data/test/dummy/app/controllers/custom/token_validations_controller.rb +2 -0
  65. data/test/dummy/app/controllers/demo_group_controller.rb +2 -0
  66. data/test/dummy/app/controllers/demo_mang_controller.rb +2 -0
  67. data/test/dummy/app/controllers/demo_user_controller.rb +2 -0
  68. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +2 -0
  69. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +2 -0
  70. data/test/dummy/app/controllers/overrides/passwords_controller.rb +2 -0
  71. data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -0
  72. data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -0
  73. data/test/dummy/app/controllers/overrides/token_validations_controller.rb +2 -0
  74. data/test/dummy/app/helpers/application_helper.rb +2 -0
  75. data/test/dummy/app/models/evil_user.rb +2 -0
  76. data/test/dummy/app/models/lockable_user.rb +2 -0
  77. data/test/dummy/app/models/mang.rb +2 -0
  78. data/test/dummy/app/models/nice_user.rb +2 -0
  79. data/test/dummy/app/models/only_email_user.rb +2 -0
  80. data/test/dummy/app/models/scoped_user.rb +2 -0
  81. data/test/dummy/app/models/unconfirmable_user.rb +2 -0
  82. data/test/dummy/app/models/unregisterable_user.rb +2 -0
  83. data/test/dummy/app/models/user.rb +2 -0
  84. data/test/dummy/config/application.rb +2 -0
  85. data/test/dummy/config/boot.rb +2 -0
  86. data/test/dummy/config/environment.rb +2 -0
  87. data/test/dummy/config/environments/development.rb +2 -0
  88. data/test/dummy/config/environments/production.rb +2 -0
  89. data/test/dummy/config/environments/test.rb +2 -0
  90. data/test/dummy/config/initializers/assets.rb +2 -0
  91. data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
  92. data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
  93. data/test/dummy/config/initializers/devise.rb +2 -0
  94. data/test/dummy/config/initializers/devise_token_auth.rb +2 -0
  95. data/test/dummy/config/initializers/figaro.rb +2 -0
  96. data/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  97. data/test/dummy/config/initializers/inflections.rb +2 -0
  98. data/test/dummy/config/initializers/mime_types.rb +2 -0
  99. data/test/dummy/config/initializers/omniauth.rb +2 -0
  100. data/test/dummy/config/initializers/session_store.rb +2 -0
  101. data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
  102. data/test/dummy/config/routes.rb +2 -0
  103. data/test/dummy/config/spring.rb +2 -0
  104. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +2 -0
  105. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +2 -0
  106. data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +2 -0
  107. data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +2 -0
  108. data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +2 -0
  109. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +2 -0
  110. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +2 -0
  111. data/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +2 -0
  112. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +2 -0
  113. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +2 -0
  114. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +2 -0
  115. data/test/dummy/lib/migration_database_helper.rb +15 -1
  116. data/test/dummy/tmp/generators/app/models/user.rb +5 -5
  117. data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +2 -0
  118. data/test/dummy/tmp/generators/db/migrate/{20171014052631_devise_token_auth_create_users.rb → 20180805205504_devise_token_auth_create_users.rb} +1 -0
  119. data/test/integration/navigation_test.rb +2 -0
  120. data/test/lib/devise_token_auth/url_test.rb +2 -0
  121. data/test/lib/generators/devise_token_auth/install_generator_test.rb +2 -0
  122. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +194 -0
  123. data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +2 -0
  124. data/test/models/only_email_user_test.rb +2 -0
  125. data/test/models/user_test.rb +6 -4
  126. data/test/test_helper.rb +30 -14
  127. metadata +23 -5
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -8,33 +10,35 @@ require 'test_helper'
8
10
 
9
11
  class Overrides::RegistrationsControllerTest < ActionDispatch::IntegrationTest
10
12
  describe Overrides::RegistrationsController do
11
- setup do
12
- @existing_user = evil_users(:confirmed_email_user)
13
- @auth_headers = @existing_user.create_new_auth_token
14
- @client_id = @auth_headers['client']
15
- @favorite_color = 'pink'
16
-
17
- # ensure request is not treated as batch request
18
- age_token(@existing_user, @client_id)
19
-
20
- # test valid update param
21
- @new_operating_thetan = 1_000_000
22
-
23
- put '/evil_user_auth',
24
- params: { favorite_color: @favorite_color },
25
- headers: @auth_headers
26
-
27
- @data = JSON.parse(response.body)
28
- @existing_user.reload
29
- end
30
-
31
- test 'user was updated' do
32
- assert_equal @favorite_color, @existing_user.favorite_color
33
- end
34
-
35
- test 'controller was overridden' do
36
- assert_equal Overrides::RegistrationsController::OVERRIDE_PROOF,
37
- @data['override_proof']
13
+ describe 'Succesful Registration update' do
14
+ setup do
15
+ @existing_user = evil_users(:confirmed_email_user)
16
+ @auth_headers = @existing_user.create_new_auth_token
17
+ @client_id = @auth_headers['client']
18
+ @favorite_color = 'pink'
19
+
20
+ # ensure request is not treated as batch request
21
+ age_token(@existing_user, @client_id)
22
+
23
+ # test valid update param
24
+ @new_operating_thetan = 1_000_000
25
+
26
+ put '/evil_user_auth',
27
+ params: { favorite_color: @favorite_color },
28
+ headers: @auth_headers
29
+
30
+ @data = JSON.parse(response.body)
31
+ @existing_user.reload
32
+ end
33
+
34
+ test 'user was updated' do
35
+ assert_equal @favorite_color, @existing_user.favorite_color
36
+ end
37
+
38
+ test 'controller was overridden' do
39
+ assert_equal Overrides::RegistrationsController::OVERRIDE_PROOF,
40
+ @data['override_proof']
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  # was the web request successful?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  include DeviseTokenAuth::Concerns::SetUserByToken
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AuthOriginController < ApplicationController
2
4
  def redirected
3
5
  head :ok
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::ConfirmationsController < DeviseTokenAuth::ConfirmationsController
2
4
 
3
5
  def show
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController
2
4
  def omniauth_success
3
5
  super do |resource|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::PasswordsController < DeviseTokenAuth::PasswordsController
2
4
 
3
5
  def create
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::RegistrationsController < DeviseTokenAuth::RegistrationsController
2
4
 
3
5
  def create
@@ -35,5 +37,4 @@ class Custom::RegistrationsController < DeviseTokenAuth::RegistrationsController
35
37
  def render_create_success
36
38
  render json: {custom: "foo"}
37
39
  end
38
-
39
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::SessionsController < DeviseTokenAuth::SessionsController
2
4
 
3
5
  def create
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Custom::TokenValidationsController < DeviseTokenAuth::TokenValidationsController
2
4
 
3
5
  def validate_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DemoGroupController < ApplicationController
2
4
  devise_token_auth_group :member, contains: [:user, :mang]
3
5
  before_action :authenticate_member!
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DemoMangController < ApplicationController
2
4
  before_action :authenticate_mang!
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DemoUserController < ApplicationController
2
4
  before_action :authenticate_user!
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overrides
2
4
  class ConfirmationsController < DeviseTokenAuth::ConfirmationsController
3
5
  def show
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overrides
2
4
  class OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController
3
5
  DEFAULT_NICKNAME = "stimpy"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overrides
2
4
  class PasswordsController < DeviseTokenAuth::PasswordsController
3
5
  OVERRIDE_PROOF = "(^^,)"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overrides
2
4
  class RegistrationsController < DeviseTokenAuth::RegistrationsController
3
5
  OVERRIDE_PROOF = "(^^,)"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overrides
2
4
  class SessionsController < DeviseTokenAuth::SessionsController
3
5
  OVERRIDE_PROOF = "(^^,)"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overrides
2
4
  class TokenValidationsController < DeviseTokenAuth::TokenValidationsController
3
5
  OVERRIDE_PROOF = '(^^,)'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationHelper
2
4
  COLOR_NAMES = [
3
5
  "Acid green",
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class EvilUser < ActiveRecord::Base
2
4
  include DeviseTokenAuth::Concerns::User
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class LockableUser < ActiveRecord::Base
2
4
  # Include default devise modules.
3
5
  devise :database_authenticatable, :registerable, :lockable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Mang < ActiveRecord::Base
2
4
  include DeviseTokenAuth::Concerns::User
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class NiceUser < ActiveRecord::Base
2
4
  # Include default devise modules.
3
5
  devise :database_authenticatable, :registerable,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class OnlyEmailUser < ActiveRecord::Base
2
4
  # Include default devise modules.
3
5
  devise :database_authenticatable, :registerable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ScopedUser < ActiveRecord::Base
2
4
  # Include default devise modules.
3
5
  devise :database_authenticatable, :registerable,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UnconfirmableUser < ActiveRecord::Base
2
4
  # Include default devise modules.
3
5
  devise :database_authenticatable, :registerable,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class UnregisterableUser < ActiveRecord::Base
2
4
  # Include default devise modules.
3
5
  devise :database_authenticatable,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class User < ActiveRecord::Base
2
4
  include DeviseTokenAuth::Concerns::User
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../boot', __FILE__)
2
4
 
3
5
  require 'rack/cors'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
4
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
4
  require File.expand_path('../application', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Version of your assets, change this if you want to expire all your assets.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
- Rails.application.config.action_dispatch.cookies_serializer = :json
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Devise.setup do |config|
2
4
  config.authentication_keys = [:email, :nickname]
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  DeviseTokenAuth.setup do |config|
2
4
  # By default the authorization headers will change after each request. The
3
5
  # client is responsible for keeping track of the changing tokens. Change
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #Figaro.require("GITHUB_KEY", "GITHUB_SECRET", "FACEBOOK_KEY", "FACEBOOK_SECRET", "GOOGLE_KEY", "GOOGLE_SECRET")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.config.middleware.use OmniAuth::Builder do |b|
2
4
  provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
3
5
  provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  Rails.application.config.session_store :cookie_store, key: '_dummy_session'