devise_jwt_auth 0.1.2 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/app/controllers/devise_jwt_auth/application_controller.rb +12 -24
  4. data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +2 -6
  5. data/app/controllers/devise_jwt_auth/concerns/{set_user_by_jwt_token.rb → set_user_by_token.rb} +23 -19
  6. data/app/controllers/devise_jwt_auth/confirmations_controller.rb +10 -19
  7. data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +32 -33
  8. data/app/controllers/devise_jwt_auth/passwords_controller.rb +34 -36
  9. data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +4 -1
  10. data/app/controllers/devise_jwt_auth/registrations_controller.rb +40 -21
  11. data/app/controllers/devise_jwt_auth/sessions_controller.rb +21 -21
  12. data/app/controllers/devise_jwt_auth/unlocks_controller.rb +5 -4
  13. data/app/models/devise_jwt_auth/concerns/active_record_support.rb +3 -0
  14. data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +7 -4
  15. data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +3 -0
  16. data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +4 -1
  17. data/app/models/devise_jwt_auth/concerns/user.rb +18 -9
  18. data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +11 -3
  19. data/app/validators/devise_jwt_auth_email_validator.rb +4 -3
  20. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  21. data/lib/devise_jwt_auth/blacklist.rb +2 -0
  22. data/lib/devise_jwt_auth/controllers/url_helpers.rb +1 -2
  23. data/lib/devise_jwt_auth/engine.rb +4 -4
  24. data/lib/devise_jwt_auth/rails/routes.rb +35 -24
  25. data/lib/devise_jwt_auth/token_factory.rb +3 -2
  26. data/lib/devise_jwt_auth/url.rb +2 -4
  27. data/lib/devise_jwt_auth/version.rb +1 -1
  28. data/lib/generators/devise_jwt_auth/install_generator.rb +7 -6
  29. data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +27 -6
  30. data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +3 -2
  31. data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +19 -20
  32. data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +15 -11
  33. data/lib/generators/devise_jwt_auth/templates/user.rb.erb +2 -2
  34. data/test/controllers/custom/custom_confirmations_controller_test.rb +2 -2
  35. data/test/controllers/custom/custom_passwords_controller_test.rb +6 -6
  36. data/test/controllers/custom/custom_refresh_token_controller_test.rb +2 -3
  37. data/test/controllers/custom/custom_registrations_controller_test.rb +2 -2
  38. data/test/controllers/demo_mang_controller_test.rb +206 -210
  39. data/test/controllers/demo_user_controller_test.rb +358 -374
  40. data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +5 -5
  41. data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +6 -7
  42. data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +29 -30
  43. data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +8 -12
  44. data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +23 -25
  45. data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +32 -34
  46. data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +2 -2
  47. data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
  48. data/test/controllers/overrides/passwords_controller_test.rb +1 -1
  49. data/test/controllers/overrides/refresh_token_controller_test.rb +1 -2
  50. data/test/controllers/overrides/registrations_controller_test.rb +1 -1
  51. data/test/dummy/app/controllers/application_controller.rb +1 -1
  52. data/test/dummy/app/controllers/custom/refresh_token_controller.rb +2 -1
  53. data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -1
  54. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -16
  55. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +4 -4
  56. data/test/dummy/app/controllers/overrides/passwords_controller.rb +4 -16
  57. data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +1 -1
  58. data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
  59. data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
  60. data/test/dummy/app/models/concerns/favorite_color.rb +11 -9
  61. data/test/dummy/config.ru +2 -2
  62. data/test/dummy/config/application.rb +1 -0
  63. data/test/dummy/config/boot.rb +1 -1
  64. data/test/dummy/config/environments/test.rb +11 -7
  65. data/test/dummy/config/initializers/figaro.rb +1 -1
  66. data/test/dummy/config/initializers/omniauth.rb +2 -2
  67. data/test/dummy/config/routes.rb +8 -8
  68. data/test/dummy/db/migrate/20141222035835_devise_jwt_auth_create_only_email_users.rb +9 -9
  69. data/test/dummy/db/migrate/20190924101113_devise_jwt_auth_create_confirmable_users.rb +6 -5
  70. data/test/dummy/db/schema.rb +170 -170
  71. data/test/dummy/tmp/generators/app/models/mang.rb +9 -0
  72. data/test/dummy/tmp/generators/app/models/{azpire/v1/human_resource/user.rb → user.rb} +3 -3
  73. data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +19 -20
  74. data/test/dummy/tmp/generators/config/routes.rb +9 -0
  75. data/test/dummy/tmp/generators/db/migrate/{20200209222205_devise_jwt_auth_create_azpire_v1_human_resource_users.rb → 20201208044024_devise_jwt_auth_create_mangs.rb} +20 -17
  76. data/test/dummy/tmp/generators/db/migrate/20201208044024_devise_jwt_auth_create_users.rb +54 -0
  77. data/test/factories/users.rb +5 -3
  78. data/test/lib/devise_jwt_auth/token_factory_test.rb +6 -6
  79. data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +3 -20
  80. data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +4 -21
  81. data/test/models/concerns/tokens_serialization_test.rb +68 -68
  82. data/test/models/user_test.rb +35 -37
  83. data/test/support/controllers/routes.rb +7 -5
  84. data/test/test_helper.rb +1 -1
  85. metadata +56 -66
  86. data/test/dummy/tmp/generators/app/controllers/application_controller.rb +0 -6
@@ -95,7 +95,7 @@ class DeviseJwtAuth::UnlocksControllerTest < ActionController::TestCase
95
95
  @data = JSON.parse(response.body)
96
96
 
97
97
  @mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
98
- @mail_reset_token = @mail.body.match(/unlock_token=(.*)\"/)[1]
98
+ @mail_reset_token = @mail.body.match(/unlock_token=(.*)"/)[1]
99
99
  end
100
100
 
101
101
  test 'response should return success status' do
@@ -161,7 +161,7 @@ class DeviseJwtAuth::UnlocksControllerTest < ActionController::TestCase
161
161
  before do
162
162
  @resource_class = LockableUser
163
163
  @request_params = {
164
- email: @resource.email.upcase
164
+ email: @resource.email.upcase
165
165
  }
166
166
  end
167
167
 
@@ -20,7 +20,7 @@ class Overrides::ConfirmationsControllerTest < ActionDispatch::IntegrationTest
20
20
  @new_user.send_confirmation_instructions(redirect_url: @redirect_url)
21
21
 
22
22
  @mail = ActionMailer::Base.deliveries.last
23
- @confirmation_path = @mail.body.match(/localhost([^\"]*)\"/)[1]
23
+ @confirmation_path = @mail.body.match(/localhost([^"]*)"/)[1]
24
24
 
25
25
  # visit confirmation link
26
26
  get @confirmation_path
@@ -24,7 +24,7 @@ class Overrides::PasswordsControllerTest < ActionDispatch::IntegrationTest
24
24
  mail = ActionMailer::Base.deliveries.last
25
25
  @resource.reload
26
26
 
27
- mail_reset_token = mail.body.match(/reset_password_token=(.*)\"/)[1]
27
+ mail_reset_token = mail.body.match(/reset_password_token=(.*)"/)[1]
28
28
  mail_redirect_url = CGI.unescape(mail.body.match(/redirect_url=([^&]*)&/)[1])
29
29
 
30
30
  get '/evil_user_auth/password/edit',
@@ -15,8 +15,7 @@ class Overrides::RefreshTokenControllerTest < ActionDispatch::IntegrationTest
15
15
  before do
16
16
  @resource = create(:user, :confirmed)
17
17
  @auth_headers = get_cookie_header(DeviseJwtAuth.refresh_token_name,
18
- @resource.create_refresh_token
19
- )
18
+ @resource.create_refresh_token)
20
19
 
21
20
  get '/evil_user_auth/refresh_token',
22
21
  params: {},
@@ -14,7 +14,7 @@ class Overrides::RegistrationsControllerTest < ActionDispatch::IntegrationTest
14
14
  describe Overrides::RegistrationsController do
15
15
  describe 'Succesful Registration update' do
16
16
  before do
17
- @existing_user = create(:user, :confirmed)
17
+ @existing_user = create(:user, :confirmed)
18
18
  @auth_headers = @existing_user.create_named_token_pair
19
19
 
20
20
  # @client_id = @auth_headers['client']
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ApplicationController < ActionController::Base
4
- include DeviseJwtAuth::Concerns::SetUserByJwtToken
4
+ include DeviseJwtAuth::Concerns::SetUserByToken
5
5
 
6
6
  before_action :configure_permitted_parameters, if: :devise_controller?
7
7
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Custom
3
4
  class RefreshTokenController < DeviseJwtAuth::RefreshTokenController
4
5
  def show
@@ -17,4 +18,4 @@ module Custom
17
18
  render json: { custom: 'foo' }
18
19
  end
19
20
  end
20
- end
21
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Custom::RegistrationsController < DeviseJwtAuth::RegistrationsController
4
4
  def create
5
- super do |resource|
5
+ super do |_resource|
6
6
  @create_block_called = true
7
7
  end
8
8
  end
@@ -5,30 +5,17 @@ module Overrides
5
5
  def show
6
6
  @resource = resource_class.confirm_by_token(params[:confirmation_token])
7
7
 
8
- if @resource && @resource.id
9
- # token = @resource.create_token
10
- # @resource.save!
11
-
8
+ if @resource&.id
12
9
  update_refresh_token_cookie
13
10
  redirect_header_options = {
14
11
  account_confirmation_success: true,
15
12
  config: params[:config],
16
13
  override_proof: '(^^,)'
17
14
  }
18
- redirect_headers = @resource.create_named_token_pair.
19
- merge(redirect_header_options)
15
+ redirect_headers = @resource.create_named_token_pair
16
+ .merge(redirect_header_options)
20
17
  redirect_to_link = DeviseJwtAuth::Url.generate(params[:redirect_url], redirect_headers)
21
18
  redirect_to redirect_to_link
22
- # redirect_header_options = {
23
- # account_confirmation_success: true,
24
- # config: params[:config],
25
- # override_proof: '(^^,)'
26
- # }
27
- # redirect_headers = build_redirect_headers(token.token,
28
- # token.client,
29
- # redirect_header_options)
30
- # redirect_to(@resource.build_auth_url(params[:redirect_url],
31
- # redirect_headers))
32
19
  else
33
20
  raise ActionController::RoutingError, 'Not Found'
34
21
  end
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Overrides
4
4
  class OmniauthCallbacksController < DeviseJwtAuth::OmniauthCallbacksController
5
- DEFAULT_NICKNAME = 'stimpy'.freeze
5
+ DEFAULT_NICKNAME = 'stimpy'
6
6
 
7
7
  def assign_provider_attrs(user, auth_hash)
8
8
  user.assign_attributes(
9
9
  nickname: DEFAULT_NICKNAME,
10
- name: auth_hash['info']['name'],
11
- image: auth_hash['info']['image'],
12
- email: auth_hash['info']['email']
10
+ name: auth_hash['info']['name'],
11
+ image: auth_hash['info']['image'],
12
+ email: auth_hash['info']['email']
13
13
  )
14
14
  end
15
15
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Overrides
4
4
  class PasswordsController < DeviseJwtAuth::PasswordsController
5
- OVERRIDE_PROOF = '(^^,)'.freeze
5
+ OVERRIDE_PROOF = '(^^,)'
6
6
 
7
7
  # this is where users arrive after visiting the email confirmation link
8
8
  def edit
@@ -10,9 +10,7 @@ module Overrides
10
10
  reset_password_token: resource_params[:reset_password_token]
11
11
  )
12
12
 
13
- if @resource && @resource.id
14
- # token = @resource.create_token
15
-
13
+ if @resource&.id
16
14
  # ensure that user is confirmed
17
15
  @resource.skip_confirmation! unless @resource.confirmed_at
18
16
 
@@ -23,20 +21,10 @@ module Overrides
23
21
  override_proof: OVERRIDE_PROOF,
24
22
  reset_password: true
25
23
  }
26
- redirect_headers = @resource.create_named_token_pair.
27
- merge(redirect_header_options)
24
+ redirect_headers = @resource.create_named_token_pair
25
+ .merge(redirect_header_options)
28
26
  redirect_to_link = DeviseJwtAuth::Url.generate(params[:redirect_url], redirect_headers)
29
27
  redirect_to redirect_to_link
30
-
31
- # redirect_header_options = {
32
- # override_proof: OVERRIDE_PROOF,
33
- # reset_password: true
34
- # }
35
- # redirect_headers = build_redirect_headers(token.token,
36
- # token.client,
37
- # redirect_header_options)
38
- # redirect_to(@resource.build_auth_url(params[:redirect_url],
39
- # redirect_headers))
40
28
  else
41
29
  raise ActionController::RoutingError, 'Not Found'
42
30
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Overrides
4
4
  class RefreshTokenController < DeviseJwtAuth::RefreshTokenController
5
- OVERRIDE_PROOF = '(^^,)'.freeze
5
+ OVERRIDE_PROOF = '(^^,)'
6
6
  def show
7
7
  # @resource will have been set by set_user_by_token concern
8
8
  if @resource
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Overrides
4
4
  class RegistrationsController < DeviseJwtAuth::RegistrationsController
5
- OVERRIDE_PROOF = '(^^,)'.freeze
5
+ OVERRIDE_PROOF = '(^^,)'
6
6
 
7
7
  def update
8
8
  if @resource
9
9
  if @resource.update(account_update_params)
10
10
  render json: {
11
11
  status: 'success',
12
- data: @resource.as_json,
12
+ data: @resource.as_json,
13
13
  override_proof: OVERRIDE_PROOF
14
14
  }
15
15
  else
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Overrides
4
4
  class SessionsController < DeviseJwtAuth::SessionsController
5
- OVERRIDE_PROOF = '(^^,)'.freeze
5
+ OVERRIDE_PROOF = '(^^,)'
6
6
 
7
7
  def create
8
8
  @resource = resource_class.dta_find_by(email: resource_params[:email])
@@ -16,7 +16,7 @@ module Overrides
16
16
  override_proof: OVERRIDE_PROOF
17
17
  }.merge(auth_header)
18
18
 
19
- elsif @resource && (not @resource.confirmed?)
19
+ elsif @resource && !@resource.confirmed?
20
20
  render json: {
21
21
  success: false,
22
22
  errors: [
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FavoriteColor
2
4
  extend ActiveSupport::Concern
3
5
 
@@ -5,15 +7,15 @@ module FavoriteColor
5
7
  validates :operating_thetan, numericality: true, allow_nil: true
6
8
  validate :ensure_correct_favorite_color
7
9
  end
8
-
10
+
9
11
  def ensure_correct_favorite_color
10
- if favorite_color && (favorite_color != '')
11
- unless ApplicationHelper::COLOR_NAMES.any?{ |s| s.casecmp(favorite_color)==0 }
12
- matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color)
13
- closest_match = matches.last[:string]
14
- second_closest_match = matches[-2][:string]
15
- errors.add(:favorite_color, "We've never heard of the color \"#{favorite_color}\". Did you mean \"#{closest_match}\"? Or perhaps \"#{second_closest_match}\"?")
16
- end
17
- end
12
+ return unless favorite_color && (favorite_color != '')
13
+
14
+ return if ApplicationHelper::COLOR_NAMES.any? { |s| s.casecmp(favorite_color).zero? }
15
+
16
+ matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color)
17
+ closest_match = matches.last[:string]
18
+ second_closest_match = matches[-2][:string]
19
+ errors.add(:favorite_color, "We've never heard of the color \"#{favorite_color}\". Did you mean \"#{closest_match}\"? Or perhaps \"#{second_closest_match}\"?")
18
20
  end
19
21
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is used by Rack-based servers to start the application.
4
4
 
5
- require ::File.expand_path('../config/environment', __FILE__)
5
+ require ::File.expand_path('config/environment', __dir__)
6
6
  run Rails.application
7
7
 
8
8
  # allow cross origin requests
@@ -12,7 +12,7 @@ use Rack::Cors do
12
12
  origins '*'
13
13
  resource '*',
14
14
  headers: :any,
15
- expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
15
+ expose: %w[access-token expiry token-type uid client],
16
16
  methods: %i[get post options delete put]
17
17
  end
18
18
  end
@@ -19,6 +19,7 @@ begin
19
19
  require 'mongoid-locker'
20
20
  end
21
21
  rescue LoadError
22
+ raise StandardError, 'Unsupported ORM'
22
23
  end
23
24
 
24
25
  require 'devise_jwt_auth'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  unless defined?(DEVISE_JWT_AUTH_ORM)
4
- DEVISE_JWT_AUTH_ORM = (ENV["DEVISE_JWT_AUTH_ORM"] || :active_record).to_sym
4
+ DEVISE_JWT_AUTH_ORM = (ENV['DEVISE_JWT_AUTH_ORM'] || :active_record).to_sym
5
5
  end
6
6
 
7
7
  # Set up gems listed in the Gemfile.
@@ -15,13 +15,17 @@ Rails.application.configure do
15
15
  config.eager_load = false
16
16
 
17
17
  # Configure static asset server for tests with Cache-Control for performance.
18
- Rails::VERSION::MAJOR == 5 ?
19
- (config.public_file_server.enabled = true) :
20
- (config.serve_static_files = true)
21
-
22
- Rails::VERSION::MAJOR == 5 ?
23
- (config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }) :
24
- (config.static_cache_control = 'public, max-age=3600')
18
+ if Rails::VERSION::MAJOR == 5
19
+ (config.public_file_server.enabled = true)
20
+ else
21
+ (config.serve_static_files = true)
22
+ end
23
+
24
+ if Rails::VERSION::MAJOR == 5
25
+ (config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' })
26
+ else
27
+ (config.static_cache_control = 'public, max-age=3600')
28
+ end
25
29
 
26
30
  # Show full error reports and disable caching.
27
31
  config.consider_all_requests_local = true
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #Figaro.require("GITHUB_KEY", "GITHUB_SECRET", "FACEBOOK_KEY", "FACEBOOK_SECRET", "GOOGLE_KEY", "GOOGLE_SECRET", "APPLE_CLIENT_ID", "APPLE_TEAM_ID", "APPLE_KEY", "APPLE_PEM")
3
+ # Figaro.require("GITHUB_KEY", "GITHUB_SECRET", "FACEBOOK_KEY", "FACEBOOK_SECRET", "GOOGLE_KEY", "GOOGLE_SECRET", "APPLE_CLIENT_ID", "APPLE_TEAM_ID", "APPLE_KEY", "APPLE_PEM")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Rails.application.config.middleware.use OmniAuth::Builder do |b|
4
- provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
3
+ Rails.application.config.middleware.use OmniAuth::Builder do |_b|
4
+ provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
5
5
  provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
6
6
  provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
7
7
  provider :apple, ENV['APPLE_CLIENT_ID'], '', { scope: 'email name', team_id: ENV['APPLE_TEAM_ID'], key_id: ENV['APPLE_KEY'], pem: ENV['APPLE_PEM'] }
@@ -32,14 +32,14 @@ Rails.application.routes.draw do
32
32
  # test namespacing with not created devise mapping
33
33
  namespace :api_v2, defaults: { format: :json } do
34
34
  mount_devise_jwt_auth_for 'ScopedUser',
35
- at: 'auth',
36
- controllers: {
37
- omniauth_callbacks: 'api_v2/omniauth_callbacks',
38
- sessions: 'api_v2/sessions',
39
- registrations: 'api_v2/registrations',
40
- confirmations: 'api_v2/confirmations',
41
- passwords: 'api_v2/passwords'
42
- }
35
+ at: 'auth',
36
+ controllers: {
37
+ omniauth_callbacks: 'api_v2/omniauth_callbacks',
38
+ sessions: 'api_v2/sessions',
39
+ registrations: 'api_v2/registrations',
40
+ confirmations: 'api_v2/confirmations',
41
+ passwords: 'api_v2/passwords'
42
+ }
43
43
  end
44
44
 
45
45
  # this route will authorize visitors using the User class
@@ -13,17 +13,17 @@ class DeviseJwtAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
13
13
  t.string :encrypted_password, null: false, default: ''
14
14
 
15
15
  ## Recoverable
16
- #t.string :reset_password_token
17
- #t.datetime :reset_password_sent_at
16
+ # t.string :reset_password_token
17
+ # t.datetime :reset_password_sent_at
18
18
 
19
19
  ## Rememberable
20
- #t.datetime :remember_created_at
20
+ # t.datetime :remember_created_at
21
21
 
22
22
  ## Confirmable
23
- #t.string :confirmation_token
24
- #t.datetime :confirmed_at
25
- #t.datetime :confirmation_sent_at
26
- #t.string :unconfirmed_email # Only if using reconfirmable
23
+ # t.string :confirmation_token
24
+ # t.datetime :confirmed_at
25
+ # t.datetime :confirmation_sent_at
26
+ # t.string :unconfirmed_email # Only if using reconfirmable
27
27
 
28
28
  ## Lockable
29
29
  # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
@@ -47,8 +47,8 @@ class DeviseJwtAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
47
47
  end
48
48
 
49
49
  add_index :only_email_users, :email
50
- add_index :only_email_users, [:uid, :provider], unique: true
51
- #add_index :only_email_users, :reset_password_token, :unique => true
50
+ add_index :only_email_users, [:uid, :provider], unique: true
51
+ # add_index :only_email_users, :reset_password_token, :unique => true
52
52
  # add_index :only_email_users, :confirmation_token, :unique => true
53
53
  # add_index :only_email_users, :unlock_token, :unique => true
54
54
  end
@@ -1,18 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DeviseJwtAuthCreateConfirmableUsers < ActiveRecord::Migration[5.2]
2
4
  def change
3
-
4
5
  create_table(:confirmable_users) do |t|
5
6
  ## Required
6
- t.string :provider, :null => false, :default => "email"
7
- t.string :uid, :null => false, :default => ""
7
+ t.string :provider, null: false, default: 'email'
8
+ t.string :uid, null: false, default: ''
8
9
 
9
10
  ## Database authenticatable
10
- t.string :encrypted_password, :null => false, :default => ""
11
+ t.string :encrypted_password, null: false, default: ''
11
12
 
12
13
  ## Recoverable
13
14
  t.string :reset_password_token
14
15
  t.datetime :reset_password_sent_at
15
- t.boolean :allow_password_change, :default => false
16
+ t.boolean :allow_password_change, default: false
16
17
 
17
18
  ## Rememberable
18
19
  t.datetime :remember_created_at
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is auto-generated from the current state of the database. Instead
2
4
  # of editing this file, please use the migrations feature of Active Record to
3
5
  # incrementally modify your database, and then regenerate this schema definition.
@@ -10,189 +12,187 @@
10
12
  #
11
13
  # It's strongly recommended that you check this file into your version control system.
12
14
 
13
- ActiveRecord::Schema.define(version: 2019_09_24_101113) do
14
-
15
- create_table "confirmable_users", force: :cascade do |t|
16
- t.string "provider", default: "email", null: false
17
- t.string "uid", default: "", null: false
18
- t.string "encrypted_password", default: "", null: false
19
- t.string "reset_password_token"
20
- t.datetime "reset_password_sent_at"
21
- t.boolean "allow_password_change", default: false
22
- t.datetime "remember_created_at"
23
- t.string "confirmation_token"
24
- t.datetime "confirmed_at"
25
- t.datetime "confirmation_sent_at"
26
- t.string "unconfirmed_email"
27
- t.string "name"
28
- t.string "nickname"
29
- t.string "image"
30
- t.string "email"
31
- t.text "tokens"
32
- t.datetime "created_at", null: false
33
- t.datetime "updated_at", null: false
34
- t.index ["confirmation_token"], name: "index_confirmable_users_on_confirmation_token", unique: true
35
- t.index ["email"], name: "index_confirmable_users_on_email", unique: true
36
- t.index ["reset_password_token"], name: "index_confirmable_users_on_reset_password_token", unique: true
37
- t.index ["uid", "provider"], name: "index_confirmable_users_on_uid_and_provider", unique: true
15
+ ActiveRecord::Schema.define(version: 20_190_924_101_113) do
16
+ create_table 'confirmable_users', force: :cascade do |t|
17
+ t.string 'provider', default: 'email', null: false
18
+ t.string 'uid', default: '', null: false
19
+ t.string 'encrypted_password', default: '', null: false
20
+ t.string 'reset_password_token'
21
+ t.datetime 'reset_password_sent_at'
22
+ t.boolean 'allow_password_change', default: false
23
+ t.datetime 'remember_created_at'
24
+ t.string 'confirmation_token'
25
+ t.datetime 'confirmed_at'
26
+ t.datetime 'confirmation_sent_at'
27
+ t.string 'unconfirmed_email'
28
+ t.string 'name'
29
+ t.string 'nickname'
30
+ t.string 'image'
31
+ t.string 'email'
32
+ t.text 'tokens'
33
+ t.datetime 'created_at', null: false
34
+ t.datetime 'updated_at', null: false
35
+ t.index ['confirmation_token'], name: 'index_confirmable_users_on_confirmation_token', unique: true
36
+ t.index ['email'], name: 'index_confirmable_users_on_email', unique: true
37
+ t.index ['reset_password_token'], name: 'index_confirmable_users_on_reset_password_token', unique: true
38
+ t.index ['uid', 'provider'], name: 'index_confirmable_users_on_uid_and_provider', unique: true
38
39
  end
39
40
 
40
- create_table "lockable_users", force: :cascade do |t|
41
- t.string "provider", null: false
42
- t.string "uid", default: "", null: false
43
- t.string "encrypted_password", default: "", null: false
44
- t.integer "failed_attempts", default: 0, null: false
45
- t.string "unlock_token"
46
- t.datetime "locked_at"
47
- t.string "name"
48
- t.string "nickname"
49
- t.string "image"
50
- t.string "email"
51
- t.text "tokens"
52
- t.datetime "created_at"
53
- t.datetime "updated_at"
54
- t.index ["email"], name: "index_lockable_users_on_email"
55
- t.index ["uid", "provider"], name: "index_lockable_users_on_uid_and_provider", unique: true
56
- t.index ["unlock_token"], name: "index_lockable_users_on_unlock_token", unique: true
41
+ create_table 'lockable_users', force: :cascade do |t|
42
+ t.string 'provider', null: false
43
+ t.string 'uid', default: '', null: false
44
+ t.string 'encrypted_password', default: '', null: false
45
+ t.integer 'failed_attempts', default: 0, null: false
46
+ t.string 'unlock_token'
47
+ t.datetime 'locked_at'
48
+ t.string 'name'
49
+ t.string 'nickname'
50
+ t.string 'image'
51
+ t.string 'email'
52
+ t.text 'tokens'
53
+ t.datetime 'created_at'
54
+ t.datetime 'updated_at'
55
+ t.index ['email'], name: 'index_lockable_users_on_email'
56
+ t.index ['uid', 'provider'], name: 'index_lockable_users_on_uid_and_provider', unique: true
57
+ t.index ['unlock_token'], name: 'index_lockable_users_on_unlock_token', unique: true
57
58
  end
58
59
 
59
- create_table "mangs", force: :cascade do |t|
60
- t.string "email"
61
- t.string "encrypted_password", default: "", null: false
62
- t.string "reset_password_token"
63
- t.datetime "reset_password_sent_at"
64
- t.string "reset_password_redirect_url"
65
- t.boolean "allow_password_change", default: false
66
- t.datetime "remember_created_at"
67
- t.string "confirmation_token"
68
- t.datetime "confirmed_at"
69
- t.datetime "confirmation_sent_at"
70
- t.string "unconfirmed_email"
71
- t.string "name"
72
- t.string "nickname"
73
- t.string "image"
74
- t.string "provider"
75
- t.string "uid", default: "", null: false
76
- t.text "tokens"
77
- t.datetime "created_at"
78
- t.datetime "updated_at"
79
- t.string "favorite_color"
80
- t.index ["confirmation_token"], name: "index_mangs_on_confirmation_token", unique: true
81
- t.index ["email"], name: "index_mangs_on_email"
82
- t.index ["reset_password_token"], name: "index_mangs_on_reset_password_token", unique: true
83
- t.index ["uid", "provider"], name: "index_mangs_on_uid_and_provider", unique: true
60
+ create_table 'mangs', force: :cascade do |t|
61
+ t.string 'email'
62
+ t.string 'encrypted_password', default: '', null: false
63
+ t.string 'reset_password_token'
64
+ t.datetime 'reset_password_sent_at'
65
+ t.string 'reset_password_redirect_url'
66
+ t.boolean 'allow_password_change', default: false
67
+ t.datetime 'remember_created_at'
68
+ t.string 'confirmation_token'
69
+ t.datetime 'confirmed_at'
70
+ t.datetime 'confirmation_sent_at'
71
+ t.string 'unconfirmed_email'
72
+ t.string 'name'
73
+ t.string 'nickname'
74
+ t.string 'image'
75
+ t.string 'provider'
76
+ t.string 'uid', default: '', null: false
77
+ t.text 'tokens'
78
+ t.datetime 'created_at'
79
+ t.datetime 'updated_at'
80
+ t.string 'favorite_color'
81
+ t.index ['confirmation_token'], name: 'index_mangs_on_confirmation_token', unique: true
82
+ t.index ['email'], name: 'index_mangs_on_email'
83
+ t.index ['reset_password_token'], name: 'index_mangs_on_reset_password_token', unique: true
84
+ t.index ['uid', 'provider'], name: 'index_mangs_on_uid_and_provider', unique: true
84
85
  end
85
86
 
86
- create_table "only_email_users", force: :cascade do |t|
87
- t.string "provider", null: false
88
- t.string "uid", default: "", null: false
89
- t.string "encrypted_password", default: "", null: false
90
- t.string "name"
91
- t.string "nickname"
92
- t.string "image"
93
- t.string "email"
94
- t.text "tokens"
95
- t.datetime "created_at"
96
- t.datetime "updated_at"
97
- t.index ["email"], name: "index_only_email_users_on_email"
98
- t.index ["uid", "provider"], name: "index_only_email_users_on_uid_and_provider", unique: true
87
+ create_table 'only_email_users', force: :cascade do |t|
88
+ t.string 'provider', null: false
89
+ t.string 'uid', default: '', null: false
90
+ t.string 'encrypted_password', default: '', null: false
91
+ t.string 'name'
92
+ t.string 'nickname'
93
+ t.string 'image'
94
+ t.string 'email'
95
+ t.text 'tokens'
96
+ t.datetime 'created_at'
97
+ t.datetime 'updated_at'
98
+ t.index ['email'], name: 'index_only_email_users_on_email'
99
+ t.index ['uid', 'provider'], name: 'index_only_email_users_on_uid_and_provider', unique: true
99
100
  end
100
101
 
101
- create_table "scoped_users", force: :cascade do |t|
102
- t.string "provider", null: false
103
- t.string "uid", default: "", null: false
104
- t.string "encrypted_password", default: "", null: false
105
- t.string "reset_password_token"
106
- t.datetime "reset_password_sent_at"
107
- t.boolean "allow_password_change", default: false
108
- t.datetime "remember_created_at"
109
- t.string "confirmation_token"
110
- t.datetime "confirmed_at"
111
- t.datetime "confirmation_sent_at"
112
- t.string "unconfirmed_email"
113
- t.string "name"
114
- t.string "nickname"
115
- t.string "image"
116
- t.string "email"
117
- t.text "tokens"
118
- t.datetime "created_at"
119
- t.datetime "updated_at"
120
- t.index ["email"], name: "index_scoped_users_on_email"
121
- t.index ["reset_password_token"], name: "index_scoped_users_on_reset_password_token", unique: true
122
- t.index ["uid", "provider"], name: "index_scoped_users_on_uid_and_provider", unique: true
102
+ create_table 'scoped_users', force: :cascade do |t|
103
+ t.string 'provider', null: false
104
+ t.string 'uid', default: '', null: false
105
+ t.string 'encrypted_password', default: '', null: false
106
+ t.string 'reset_password_token'
107
+ t.datetime 'reset_password_sent_at'
108
+ t.boolean 'allow_password_change', default: false
109
+ t.datetime 'remember_created_at'
110
+ t.string 'confirmation_token'
111
+ t.datetime 'confirmed_at'
112
+ t.datetime 'confirmation_sent_at'
113
+ t.string 'unconfirmed_email'
114
+ t.string 'name'
115
+ t.string 'nickname'
116
+ t.string 'image'
117
+ t.string 'email'
118
+ t.text 'tokens'
119
+ t.datetime 'created_at'
120
+ t.datetime 'updated_at'
121
+ t.index ['email'], name: 'index_scoped_users_on_email'
122
+ t.index ['reset_password_token'], name: 'index_scoped_users_on_reset_password_token', unique: true
123
+ t.index ['uid', 'provider'], name: 'index_scoped_users_on_uid_and_provider', unique: true
123
124
  end
124
125
 
125
- create_table "unconfirmable_users", force: :cascade do |t|
126
- t.string "provider", null: false
127
- t.string "uid", default: "", null: false
128
- t.string "encrypted_password", default: "", null: false
129
- t.string "reset_password_token"
130
- t.datetime "reset_password_sent_at"
131
- t.boolean "allow_password_change", default: false
132
- t.datetime "remember_created_at"
133
- t.string "name"
134
- t.string "nickname"
135
- t.string "image"
136
- t.string "email"
137
- t.text "tokens"
138
- t.datetime "created_at"
139
- t.datetime "updated_at"
140
- t.index ["email"], name: "index_unconfirmable_users_on_email"
141
- t.index ["reset_password_token"], name: "index_unconfirmable_users_on_reset_password_token", unique: true
142
- t.index ["uid", "provider"], name: "index_unconfirmable_users_on_uid_and_provider", unique: true
126
+ create_table 'unconfirmable_users', force: :cascade do |t|
127
+ t.string 'provider', null: false
128
+ t.string 'uid', default: '', null: false
129
+ t.string 'encrypted_password', default: '', null: false
130
+ t.string 'reset_password_token'
131
+ t.datetime 'reset_password_sent_at'
132
+ t.boolean 'allow_password_change', default: false
133
+ t.datetime 'remember_created_at'
134
+ t.string 'name'
135
+ t.string 'nickname'
136
+ t.string 'image'
137
+ t.string 'email'
138
+ t.text 'tokens'
139
+ t.datetime 'created_at'
140
+ t.datetime 'updated_at'
141
+ t.index ['email'], name: 'index_unconfirmable_users_on_email'
142
+ t.index ['reset_password_token'], name: 'index_unconfirmable_users_on_reset_password_token', unique: true
143
+ t.index ['uid', 'provider'], name: 'index_unconfirmable_users_on_uid_and_provider', unique: true
143
144
  end
144
145
 
145
- create_table "unregisterable_users", force: :cascade do |t|
146
- t.string "provider", null: false
147
- t.string "uid", default: "", null: false
148
- t.string "encrypted_password", default: "", null: false
149
- t.string "reset_password_token"
150
- t.datetime "reset_password_sent_at"
151
- t.boolean "allow_password_change", default: false
152
- t.datetime "remember_created_at"
153
- t.string "confirmation_token"
154
- t.datetime "confirmed_at"
155
- t.datetime "confirmation_sent_at"
156
- t.string "unconfirmed_email"
157
- t.string "name"
158
- t.string "nickname"
159
- t.string "image"
160
- t.string "email"
161
- t.text "tokens"
162
- t.datetime "created_at"
163
- t.datetime "updated_at"
164
- t.index ["email"], name: "index_unregisterable_users_on_email"
165
- t.index ["reset_password_token"], name: "index_unregisterable_users_on_reset_password_token", unique: true
166
- t.index ["uid", "provider"], name: "index_unregisterable_users_on_uid_and_provider", unique: true
146
+ create_table 'unregisterable_users', force: :cascade do |t|
147
+ t.string 'provider', null: false
148
+ t.string 'uid', default: '', null: false
149
+ t.string 'encrypted_password', default: '', null: false
150
+ t.string 'reset_password_token'
151
+ t.datetime 'reset_password_sent_at'
152
+ t.boolean 'allow_password_change', default: false
153
+ t.datetime 'remember_created_at'
154
+ t.string 'confirmation_token'
155
+ t.datetime 'confirmed_at'
156
+ t.datetime 'confirmation_sent_at'
157
+ t.string 'unconfirmed_email'
158
+ t.string 'name'
159
+ t.string 'nickname'
160
+ t.string 'image'
161
+ t.string 'email'
162
+ t.text 'tokens'
163
+ t.datetime 'created_at'
164
+ t.datetime 'updated_at'
165
+ t.index ['email'], name: 'index_unregisterable_users_on_email'
166
+ t.index ['reset_password_token'], name: 'index_unregisterable_users_on_reset_password_token', unique: true
167
+ t.index ['uid', 'provider'], name: 'index_unregisterable_users_on_uid_and_provider', unique: true
167
168
  end
168
169
 
169
- create_table "users", force: :cascade do |t|
170
- t.string "email"
171
- t.string "encrypted_password", default: "", null: false
172
- t.string "reset_password_token"
173
- t.datetime "reset_password_sent_at"
174
- t.string "reset_password_redirect_url"
175
- t.boolean "allow_password_change", default: false
176
- t.datetime "remember_created_at"
177
- t.string "confirmation_token"
178
- t.datetime "confirmed_at"
179
- t.datetime "confirmation_sent_at"
180
- t.string "unconfirmed_email"
181
- t.string "name"
182
- t.string "nickname"
183
- t.string "image"
184
- t.string "provider"
185
- t.string "uid", default: "", null: false
186
- t.text "tokens"
187
- t.datetime "created_at"
188
- t.datetime "updated_at"
189
- t.integer "operating_thetan"
190
- t.string "favorite_color"
191
- t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
192
- t.index ["email"], name: "index_users_on_email"
193
- t.index ["nickname"], name: "index_users_on_nickname", unique: true
194
- t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
195
- t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
170
+ create_table 'users', force: :cascade do |t|
171
+ t.string 'email'
172
+ t.string 'encrypted_password', default: '', null: false
173
+ t.string 'reset_password_token'
174
+ t.datetime 'reset_password_sent_at'
175
+ t.string 'reset_password_redirect_url'
176
+ t.boolean 'allow_password_change', default: false
177
+ t.datetime 'remember_created_at'
178
+ t.string 'confirmation_token'
179
+ t.datetime 'confirmed_at'
180
+ t.datetime 'confirmation_sent_at'
181
+ t.string 'unconfirmed_email'
182
+ t.string 'name'
183
+ t.string 'nickname'
184
+ t.string 'image'
185
+ t.string 'provider'
186
+ t.string 'uid', default: '', null: false
187
+ t.text 'tokens'
188
+ t.datetime 'created_at'
189
+ t.datetime 'updated_at'
190
+ t.integer 'operating_thetan'
191
+ t.string 'favorite_color'
192
+ t.index ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true
193
+ t.index ['email'], name: 'index_users_on_email'
194
+ t.index ['nickname'], name: 'index_users_on_nickname', unique: true
195
+ t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
196
+ t.index ['uid', 'provider'], name: 'index_users_on_uid_and_provider', unique: true
196
197
  end
197
-
198
198
  end