digix_devise_token_auth 0.1.44

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.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +952 -0
  4. data/Rakefile +35 -0
  5. data/app/controllers/devise_token_auth/application_controller.rb +76 -0
  6. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +43 -0
  7. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +165 -0
  8. data/app/controllers/devise_token_auth/confirmations_controller.rb +30 -0
  9. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +243 -0
  10. data/app/controllers/devise_token_auth/passwords_controller.rb +202 -0
  11. data/app/controllers/devise_token_auth/registrations_controller.rb +205 -0
  12. data/app/controllers/devise_token_auth/sessions_controller.rb +133 -0
  13. data/app/controllers/devise_token_auth/token_validations_controller.rb +29 -0
  14. data/app/controllers/devise_token_auth/unlocks_controller.rb +89 -0
  15. data/app/models/devise_token_auth/concerns/user.rb +260 -0
  16. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +26 -0
  17. data/app/validators/email_validator.rb +21 -0
  18. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  19. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  20. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  21. data/app/views/devise_token_auth/omniauth_external_window.html.erb +38 -0
  22. data/config/initializers/devise.rb +196 -0
  23. data/config/locales/da-DK.yml +50 -0
  24. data/config/locales/de.yml +49 -0
  25. data/config/locales/en.yml +50 -0
  26. data/config/locales/es.yml +49 -0
  27. data/config/locales/fr.yml +49 -0
  28. data/config/locales/it.yml +46 -0
  29. data/config/locales/ja.yml +46 -0
  30. data/config/locales/nl.yml +30 -0
  31. data/config/locales/pl.yml +48 -0
  32. data/config/locales/pt-BR.yml +46 -0
  33. data/config/locales/pt.yml +48 -0
  34. data/config/locales/ro.yml +46 -0
  35. data/config/locales/ru.yml +50 -0
  36. data/config/locales/sq.yml +46 -0
  37. data/config/locales/uk.yml +59 -0
  38. data/config/locales/vi.yml +50 -0
  39. data/config/locales/zh-CN.yml +46 -0
  40. data/config/locales/zh-HK.yml +48 -0
  41. data/config/locales/zh-TW.yml +48 -0
  42. data/lib/devise_token_auth.rb +8 -0
  43. data/lib/devise_token_auth/controllers/helpers.rb +149 -0
  44. data/lib/devise_token_auth/controllers/url_helpers.rb +8 -0
  45. data/lib/devise_token_auth/engine.rb +90 -0
  46. data/lib/devise_token_auth/rails/routes.rb +114 -0
  47. data/lib/devise_token_auth/url.rb +37 -0
  48. data/lib/devise_token_auth/version.rb +3 -0
  49. data/lib/generators/devise_token_auth/USAGE +31 -0
  50. data/lib/generators/devise_token_auth/install_generator.rb +160 -0
  51. data/lib/generators/devise_token_auth/install_views_generator.rb +16 -0
  52. data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +48 -0
  53. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +55 -0
  54. data/lib/generators/devise_token_auth/templates/user.rb +7 -0
  55. data/lib/tasks/devise_token_auth_tasks.rake +4 -0
  56. data/test/controllers/custom/custom_confirmations_controller_test.rb +21 -0
  57. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +29 -0
  58. data/test/controllers/custom/custom_passwords_controller_test.rb +75 -0
  59. data/test/controllers/custom/custom_registrations_controller_test.rb +54 -0
  60. data/test/controllers/custom/custom_sessions_controller_test.rb +37 -0
  61. data/test/controllers/custom/custom_token_validations_controller_test.rb +40 -0
  62. data/test/controllers/demo_group_controller_test.rb +153 -0
  63. data/test/controllers/demo_mang_controller_test.rb +284 -0
  64. data/test/controllers/demo_user_controller_test.rb +601 -0
  65. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +129 -0
  66. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +371 -0
  67. data/test/controllers/devise_token_auth/passwords_controller_test.rb +649 -0
  68. data/test/controllers/devise_token_auth/registrations_controller_test.rb +878 -0
  69. data/test/controllers/devise_token_auth/sessions_controller_test.rb +500 -0
  70. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +90 -0
  71. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +194 -0
  72. data/test/controllers/overrides/confirmations_controller_test.rb +43 -0
  73. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +49 -0
  74. data/test/controllers/overrides/passwords_controller_test.rb +66 -0
  75. data/test/controllers/overrides/registrations_controller_test.rb +40 -0
  76. data/test/controllers/overrides/sessions_controller_test.rb +33 -0
  77. data/test/controllers/overrides/token_validations_controller_test.rb +41 -0
  78. data/test/dummy/README.rdoc +28 -0
  79. data/test/dummy/app/controllers/application_controller.rb +16 -0
  80. data/test/dummy/app/controllers/auth_origin_controller.rb +5 -0
  81. data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
  82. data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +11 -0
  83. data/test/dummy/app/controllers/custom/passwords_controller.rb +40 -0
  84. data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
  85. data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
  86. data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
  87. data/test/dummy/app/controllers/demo_group_controller.rb +13 -0
  88. data/test/dummy/app/controllers/demo_mang_controller.rb +12 -0
  89. data/test/dummy/app/controllers/demo_user_controller.rb +25 -0
  90. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +26 -0
  91. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +14 -0
  92. data/test/dummy/app/controllers/overrides/passwords_controller.rb +33 -0
  93. data/test/dummy/app/controllers/overrides/registrations_controller.rb +27 -0
  94. data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
  95. data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
  96. data/test/dummy/app/helpers/application_helper.rb +1065 -0
  97. data/test/dummy/app/models/evil_user.rb +3 -0
  98. data/test/dummy/app/models/lockable_user.rb +5 -0
  99. data/test/dummy/app/models/mang.rb +3 -0
  100. data/test/dummy/app/models/nice_user.rb +7 -0
  101. data/test/dummy/app/models/only_email_user.rb +5 -0
  102. data/test/dummy/app/models/scoped_user.rb +7 -0
  103. data/test/dummy/app/models/unconfirmable_user.rb +8 -0
  104. data/test/dummy/app/models/unregisterable_user.rb +7 -0
  105. data/test/dummy/app/models/user.rb +18 -0
  106. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  107. data/test/dummy/config.ru +16 -0
  108. data/test/dummy/config/application.rb +24 -0
  109. data/test/dummy/config/application.yml.bk +0 -0
  110. data/test/dummy/config/boot.rb +5 -0
  111. data/test/dummy/config/environment.rb +5 -0
  112. data/test/dummy/config/environments/development.rb +44 -0
  113. data/test/dummy/config/environments/production.rb +82 -0
  114. data/test/dummy/config/environments/test.rb +48 -0
  115. data/test/dummy/config/initializers/assets.rb +8 -0
  116. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  117. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  118. data/test/dummy/config/initializers/devise.rb +3 -0
  119. data/test/dummy/config/initializers/devise_token_auth.rb +22 -0
  120. data/test/dummy/config/initializers/figaro.rb +1 -0
  121. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  122. data/test/dummy/config/initializers/inflections.rb +16 -0
  123. data/test/dummy/config/initializers/mime_types.rb +4 -0
  124. data/test/dummy/config/initializers/omniauth.rb +8 -0
  125. data/test/dummy/config/initializers/session_store.rb +3 -0
  126. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  127. data/test/dummy/config/routes.rb +72 -0
  128. data/test/dummy/config/spring.rb +1 -0
  129. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +63 -0
  130. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +62 -0
  131. data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +6 -0
  132. data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +5 -0
  133. data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +64 -0
  134. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +60 -0
  135. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +61 -0
  136. data/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +61 -0
  137. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +61 -0
  138. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +61 -0
  139. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +61 -0
  140. data/test/dummy/db/schema.rb +258 -0
  141. data/test/dummy/lib/migration_database_helper.rb +29 -0
  142. data/test/integration/navigation_test.rb +10 -0
  143. data/test/lib/devise_token_auth/url_test.rb +24 -0
  144. data/test/lib/generators/devise_token_auth/install_generator_test.rb +187 -0
  145. data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +23 -0
  146. data/test/models/only_email_user_test.rb +35 -0
  147. data/test/models/user_test.rb +169 -0
  148. data/test/test_helper.rb +77 -0
  149. metadata +342 -0
@@ -0,0 +1,72 @@
1
+ Rails.application.routes.draw do
2
+ # when using multiple models, controllers will default to the first available
3
+ # devise mapping. routes for subsequent devise mappings will need to defined
4
+ # within a `devise_scope` block
5
+
6
+ # define :users as the first devise mapping:
7
+ mount_devise_token_auth_for 'User', at: 'auth'
8
+
9
+ # define :mangs as the second devise mapping. routes using this class will
10
+ # need to be defined within a devise_scope as shown below
11
+ mount_devise_token_auth_for "Mang", at: 'mangs'
12
+
13
+ mount_devise_token_auth_for 'EvilUser', at: 'evil_user_auth', controllers: {
14
+ confirmations: 'overrides/confirmations',
15
+ passwords: 'overrides/passwords',
16
+ omniauth_callbacks: 'overrides/omniauth_callbacks',
17
+ registrations: 'overrides/registrations',
18
+ sessions: 'overrides/sessions',
19
+ token_validations: 'overrides/token_validations'
20
+ }
21
+
22
+ mount_devise_token_auth_for 'NiceUser', at: 'nice_user_auth', controllers: {
23
+ registrations: 'custom/registrations',
24
+ confirmations: 'custom/confirmations',
25
+ passwords: 'custom/passwords',
26
+ sessions: 'custom/sessions',
27
+ token_validations: 'custom/token_validations',
28
+ omniauth_callbacks: 'custom/omniauth_callbacks'
29
+ }
30
+
31
+ mount_devise_token_auth_for 'OnlyEmailUser', at: 'only_email_auth', skip: [:omniauth_callbacks]
32
+
33
+ mount_devise_token_auth_for 'UnregisterableUser', at: 'unregisterable_user_auth', skip: [:registrations]
34
+
35
+ mount_devise_token_auth_for 'UnconfirmableUser', at: 'unconfirmable_user_auth'
36
+
37
+ mount_devise_token_auth_for 'LockableUser', at: 'lockable_user_auth'
38
+
39
+ # test namespacing
40
+ namespace :api do
41
+ scope :v1 do
42
+ mount_devise_token_auth_for 'User', at: 'auth'
43
+ end
44
+ end
45
+
46
+ # test namespacing with not created devise mapping
47
+ namespace :api_v2, defaults: { format: :json } do
48
+ mount_devise_token_auth_for "ScopedUser",
49
+ at: "auth",
50
+ controllers: {
51
+ omniauth_callbacks: "api_v2/omniauth_callbacks",
52
+ sessions: "api_v2/sessions",
53
+ registrations: "api_v2/registrations",
54
+ confirmations: "api_v2/confirmations",
55
+ passwords: "api_v2/passwords"
56
+ }
57
+ end
58
+
59
+ # this route will authorize visitors using the User class
60
+ get 'demo/members_only', to: 'demo_user#members_only'
61
+ get 'demo/members_only_remove_token', to: 'demo_user#members_only_remove_token'
62
+
63
+
64
+ # routes within this block will authorize visitors using the Mang class
65
+ get 'demo/members_only_mang', to: 'demo_mang#members_only'
66
+
67
+ # routes within this block will authorize visitors using the Mang or User class
68
+ get 'demo/members_only_group', to: 'demo_group#members_only'
69
+
70
+ # we need a route for omniauth_callback_controller to redirect to in sameWindow case
71
+ get 'auth_origin', to: 'auth_origin#redirected'
72
+ end
@@ -0,0 +1 @@
1
+ Spring.application_root = './test/dummy'
@@ -0,0 +1,63 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[4.2]
4
+ def change
5
+ create_table(:users) do |t|
6
+ ## Database authenticatable
7
+ t.string :email
8
+ t.string :encrypted_password, :null => false, :default => ""
9
+
10
+ ## Recoverable
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+ t.string :reset_password_redirect_url
14
+ t.boolean :allow_password_change, :default => false
15
+
16
+ ## Rememberable
17
+ t.datetime :remember_created_at
18
+
19
+ ## Trackable
20
+ t.integer :sign_in_count, :default => 0, :null => false
21
+ t.datetime :current_sign_in_at
22
+ t.datetime :last_sign_in_at
23
+ t.string :current_sign_in_ip
24
+ t.string :last_sign_in_ip
25
+
26
+ ## Confirmable
27
+ t.string :confirmation_token
28
+ t.datetime :confirmed_at
29
+ t.datetime :confirmation_sent_at
30
+ t.string :unconfirmed_email # Only if using reconfirmable
31
+
32
+ ## Lockable
33
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
34
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
35
+ # t.datetime :locked_at
36
+
37
+ ## User Info
38
+ t.string :name
39
+ t.string :nickname
40
+ t.string :image
41
+
42
+ ## unique oauth id
43
+ t.string :provider
44
+ t.string :uid, :null => false, :default => ""
45
+
46
+ ## Tokens
47
+ if json_supported_database?
48
+ t.json :tokens
49
+ else
50
+ t.text :tokens
51
+ end
52
+
53
+ t.timestamps
54
+ end
55
+
56
+ add_index :users, :email
57
+ add_index :users, [:uid, :provider], :unique => true
58
+ add_index :users, :reset_password_token, :unique => true
59
+ add_index :users, :confirmation_token, :unique => true
60
+ add_index :users, :nickname, :unique => true
61
+ # add_index :users, :unlock_token, :unique => true
62
+ end
63
+ end
@@ -0,0 +1,62 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateMangs < ActiveRecord::Migration[4.2]
4
+ def change
5
+ create_table(:mangs) do |t|
6
+ ## Database authenticatable
7
+ t.string :email
8
+ t.string :encrypted_password, :null => false, :default => ""
9
+
10
+ ## Recoverable
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+ t.string :reset_password_redirect_url
14
+ t.boolean :allow_password_change, :default => false
15
+
16
+ ## Rememberable
17
+ t.datetime :remember_created_at
18
+
19
+ ## Trackable
20
+ t.integer :sign_in_count, :default => 0, :null => false
21
+ t.datetime :current_sign_in_at
22
+ t.datetime :last_sign_in_at
23
+ t.string :current_sign_in_ip
24
+ t.string :last_sign_in_ip
25
+
26
+ ## Confirmable
27
+ t.string :confirmation_token
28
+ t.datetime :confirmed_at
29
+ t.datetime :confirmation_sent_at
30
+ t.string :unconfirmed_email # Only if using reconfirmable
31
+
32
+ ## Lockable
33
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
34
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
35
+ # t.datetime :locked_at
36
+
37
+ ## User Info
38
+ t.string :name
39
+ t.string :nickname
40
+ t.string :image
41
+
42
+ ## unique oauth id
43
+ t.string :provider
44
+ t.string :uid, :null => false, :default => ""
45
+
46
+ ## Tokens
47
+ if json_supported_database?
48
+ t.json :tokens
49
+ else
50
+ t.text :tokens
51
+ end
52
+
53
+ t.timestamps
54
+ end
55
+
56
+ add_index :mangs, :email
57
+ add_index :mangs, [:uid, :provider], :unique => true
58
+ add_index :mangs, :reset_password_token, :unique => true
59
+ add_index :mangs, :confirmation_token, :unique => true
60
+ # add_index :mangs, :unlock_token, :unique => true
61
+ end
62
+ end
@@ -0,0 +1,6 @@
1
+ class AddOperatingThetanToUser < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :users, :operating_thetan, :integer
4
+ add_column :users, :favorite_color, :string
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddFavoriteColorToMangs < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :mangs, :favorite_color, :string
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateEvilUsers < ActiveRecord::Migration[4.2]
4
+ def change
5
+ create_table(:evil_users) do |t|
6
+ ## Database authenticatable
7
+ t.string :email
8
+ t.string :encrypted_password, :null => false, :default => ""
9
+
10
+ ## Recoverable
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+ t.boolean :allow_password_change, :default => false
14
+
15
+ ## Rememberable
16
+ t.datetime :remember_created_at
17
+
18
+ ## Trackable
19
+ t.integer :sign_in_count, :default => 0, :null => false
20
+ t.datetime :current_sign_in_at
21
+ t.datetime :last_sign_in_at
22
+ t.string :current_sign_in_ip
23
+ t.string :last_sign_in_ip
24
+
25
+ ## Confirmable
26
+ t.string :confirmation_token
27
+ t.datetime :confirmed_at
28
+ t.datetime :confirmation_sent_at
29
+ t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Lockable
32
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
33
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
34
+ # t.datetime :locked_at
35
+
36
+ ## User Info
37
+ t.string :name
38
+ t.string :nickname
39
+ t.string :image
40
+
41
+ ## unique oauth id
42
+ t.string :provider
43
+ t.string :uid, :null => false, :default => ""
44
+
45
+ ## Tokens
46
+ if json_supported_database?
47
+ t.json :tokens
48
+ else
49
+ t.text :tokens
50
+ end
51
+
52
+ ## etc.
53
+ t.string :favorite_color
54
+
55
+ t.timestamps
56
+ end
57
+
58
+ add_index :evil_users, :email
59
+ add_index :evil_users, [:uid, :provider], :unique => true
60
+ add_index :evil_users, :reset_password_token, :unique => true
61
+ add_index :evil_users, :confirmation_token, :unique => true
62
+ # add_index :evil_users, :unlock_token, :unique => true
63
+ end
64
+ end
@@ -0,0 +1,60 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
4
+ def change
5
+ create_table(:only_email_users) do |t|
6
+ ## Required
7
+ t.string :provider, :null => false
8
+ t.string :uid, :null => false, :default => ""
9
+
10
+ ## Database authenticatable
11
+ t.string :encrypted_password, :null => false, :default => ""
12
+
13
+ ## Recoverable
14
+ #t.string :reset_password_token
15
+ #t.datetime :reset_password_sent_at
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
+ t.string :email
43
+
44
+ ## Tokens
45
+ if json_supported_database?
46
+ t.json :tokens
47
+ else
48
+ t.text :tokens
49
+ end
50
+
51
+ t.timestamps
52
+ end
53
+
54
+ add_index :only_email_users, :email
55
+ add_index :only_email_users, [:uid, :provider], :unique => true
56
+ #add_index :only_email_users, :reset_password_token, :unique => true
57
+ # add_index :only_email_users, :confirmation_token, :unique => true
58
+ # add_index :only_email_users, :unlock_token, :unique => true
59
+ end
60
+ end
@@ -0,0 +1,61 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateUnregisterableUsers < ActiveRecord::Migration[4.2]
4
+ def change
5
+ create_table(:unregisterable_users) do |t|
6
+ ## Required
7
+ t.string :provider, :null => false
8
+ t.string :uid, :null => false, :default => ""
9
+
10
+ ## Database authenticatable
11
+ t.string :encrypted_password, :null => false, :default => ""
12
+
13
+ ## Recoverable
14
+ t.string :reset_password_token
15
+ t.datetime :reset_password_sent_at
16
+ t.boolean :allow_password_change, :default => false
17
+
18
+ ## Rememberable
19
+ t.datetime :remember_created_at
20
+
21
+ ## Trackable
22
+ t.integer :sign_in_count, :default => 0, :null => false
23
+ t.datetime :current_sign_in_at
24
+ t.datetime :last_sign_in_at
25
+ t.string :current_sign_in_ip
26
+ t.string :last_sign_in_ip
27
+
28
+ ## Confirmable
29
+ t.string :confirmation_token
30
+ t.datetime :confirmed_at
31
+ t.datetime :confirmation_sent_at
32
+ t.string :unconfirmed_email # Only if using reconfirmable
33
+
34
+ ## Lockable
35
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
36
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
37
+ # t.datetime :locked_at
38
+
39
+ ## User Info
40
+ t.string :name
41
+ t.string :nickname
42
+ t.string :image
43
+ t.string :email
44
+
45
+ ## Tokens
46
+ if json_supported_database?
47
+ t.json :tokens
48
+ else
49
+ t.text :tokens
50
+ end
51
+
52
+ t.timestamps
53
+ end
54
+
55
+ add_index :unregisterable_users, :email
56
+ add_index :unregisterable_users, [:uid, :provider], :unique => true
57
+ add_index :unregisterable_users, :reset_password_token, :unique => true
58
+ # add_index :unregisterable_users, :confirmation_token, :unique => true
59
+ # add_index :unregisterable_users, :unlock_token, :unique => true
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ include MigrationDatabaseHelper
2
+
3
+ class DeviseTokenAuthCreateNiceUsers < ActiveRecord::Migration[4.2]
4
+ def change
5
+ create_table(:nice_users) do |t|
6
+ ## Required
7
+ t.string :provider, :null => false
8
+ t.string :uid, :null => false, :default => ""
9
+
10
+ ## Database authenticatable
11
+ t.string :encrypted_password, :null => false, :default => ""
12
+
13
+ ## Recoverable
14
+ t.string :reset_password_token
15
+ t.datetime :reset_password_sent_at
16
+ t.boolean :allow_password_change, :default => false
17
+
18
+ ## Rememberable
19
+ t.datetime :remember_created_at
20
+
21
+ ## Trackable
22
+ t.integer :sign_in_count, :default => 0, :null => false
23
+ t.datetime :current_sign_in_at
24
+ t.datetime :last_sign_in_at
25
+ t.string :current_sign_in_ip
26
+ t.string :last_sign_in_ip
27
+
28
+ ## Confirmable
29
+ t.string :confirmation_token
30
+ t.datetime :confirmed_at
31
+ t.datetime :confirmation_sent_at
32
+ t.string :unconfirmed_email # Only if using reconfirmable
33
+
34
+ ## Lockable
35
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
36
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
37
+ # t.datetime :locked_at
38
+
39
+ ## User Info
40
+ t.string :name
41
+ t.string :nickname
42
+ t.string :image
43
+ t.string :email
44
+
45
+ ## Tokens
46
+ if json_supported_database?
47
+ t.json :tokens
48
+ else
49
+ t.text :tokens
50
+ end
51
+
52
+ t.timestamps
53
+ end
54
+
55
+ add_index :nice_users, :email
56
+ add_index :nice_users, [:uid, :provider], :unique => true
57
+ add_index :nice_users, :reset_password_token, :unique => true
58
+ # add_index :nice_users, :confirmation_token, :unique => true
59
+ # add_index :nice_users, :unlock_token, :unique => true
60
+ end
61
+ end