devise_token_auth_multi_email 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +97 -0
  4. data/Rakefile +42 -0
  5. data/app/controllers/devise_token_auth/application_controller.rb +100 -0
  6. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +68 -0
  7. data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +199 -0
  8. data/app/controllers/devise_token_auth/confirmations_controller.rb +89 -0
  9. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +284 -0
  10. data/app/controllers/devise_token_auth/passwords_controller.rb +216 -0
  11. data/app/controllers/devise_token_auth/registrations_controller.rb +205 -0
  12. data/app/controllers/devise_token_auth/sessions_controller.rb +153 -0
  13. data/app/controllers/devise_token_auth/token_validations_controller.rb +31 -0
  14. data/app/controllers/devise_token_auth/unlocks_controller.rb +94 -0
  15. data/app/models/devise_token_auth/concerns/active_record_support.rb +18 -0
  16. data/app/models/devise_token_auth/concerns/confirmable_support.rb +28 -0
  17. data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
  18. data/app/models/devise_token_auth/concerns/tokens_serialization.rb +31 -0
  19. data/app/models/devise_token_auth/concerns/user.rb +282 -0
  20. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +39 -0
  21. data/app/validators/devise_token_auth_email_validator.rb +31 -0
  22. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  23. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  24. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  25. data/app/views/devise_token_auth/omniauth_external_window.html.erb +38 -0
  26. data/config/locales/da-DK.yml +52 -0
  27. data/config/locales/de.yml +51 -0
  28. data/config/locales/en.yml +60 -0
  29. data/config/locales/es.yml +51 -0
  30. data/config/locales/fa.yml +60 -0
  31. data/config/locales/fr.yml +51 -0
  32. data/config/locales/he.yml +52 -0
  33. data/config/locales/it.yml +48 -0
  34. data/config/locales/ja.yml +60 -0
  35. data/config/locales/ko.yml +51 -0
  36. data/config/locales/nl.yml +32 -0
  37. data/config/locales/pl.yml +51 -0
  38. data/config/locales/pt-BR.yml +48 -0
  39. data/config/locales/pt.yml +51 -0
  40. data/config/locales/ro.yml +48 -0
  41. data/config/locales/ru.yml +52 -0
  42. data/config/locales/sq.yml +48 -0
  43. data/config/locales/sv.yml +52 -0
  44. data/config/locales/uk.yml +61 -0
  45. data/config/locales/vi.yml +52 -0
  46. data/config/locales/zh-CN.yml +48 -0
  47. data/config/locales/zh-HK.yml +50 -0
  48. data/config/locales/zh-TW.yml +50 -0
  49. data/lib/devise_token_auth/blacklist.rb +6 -0
  50. data/lib/devise_token_auth/controllers/helpers.rb +157 -0
  51. data/lib/devise_token_auth/controllers/url_helpers.rb +10 -0
  52. data/lib/devise_token_auth/engine.rb +105 -0
  53. data/lib/devise_token_auth/errors.rb +8 -0
  54. data/lib/devise_token_auth/rails/routes.rb +122 -0
  55. data/lib/devise_token_auth/token_factory.rb +126 -0
  56. data/lib/devise_token_auth/url.rb +44 -0
  57. data/lib/devise_token_auth/version.rb +5 -0
  58. data/lib/devise_token_auth.rb +14 -0
  59. data/lib/generators/devise_token_auth/USAGE +31 -0
  60. data/lib/generators/devise_token_auth/install_generator.rb +91 -0
  61. data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
  62. data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
  63. data/lib/generators/devise_token_auth/install_views_generator.rb +18 -0
  64. data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +66 -0
  65. data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +49 -0
  66. data/lib/generators/devise_token_auth/templates/user.rb.erb +9 -0
  67. data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +56 -0
  68. data/lib/tasks/devise_token_auth_tasks.rake +6 -0
  69. data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
  70. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
  71. data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
  72. data/test/controllers/custom/custom_registrations_controller_test.rb +63 -0
  73. data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
  74. data/test/controllers/custom/custom_token_validations_controller_test.rb +42 -0
  75. data/test/controllers/demo_group_controller_test.rb +151 -0
  76. data/test/controllers/demo_mang_controller_test.rb +313 -0
  77. data/test/controllers/demo_user_controller_test.rb +658 -0
  78. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +275 -0
  79. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +438 -0
  80. data/test/controllers/devise_token_auth/passwords_controller_test.rb +893 -0
  81. data/test/controllers/devise_token_auth/registrations_controller_test.rb +920 -0
  82. data/test/controllers/devise_token_auth/sessions_controller_test.rb +605 -0
  83. data/test/controllers/devise_token_auth/token_validations_controller_test.rb +142 -0
  84. data/test/controllers/devise_token_auth/unlocks_controller_test.rb +235 -0
  85. data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
  86. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
  87. data/test/controllers/overrides/passwords_controller_test.rb +64 -0
  88. data/test/controllers/overrides/registrations_controller_test.rb +46 -0
  89. data/test/controllers/overrides/sessions_controller_test.rb +35 -0
  90. data/test/controllers/overrides/token_validations_controller_test.rb +43 -0
  91. data/test/dummy/README.rdoc +28 -0
  92. data/test/dummy/app/active_record/confirmable_user.rb +11 -0
  93. data/test/dummy/app/active_record/lockable_user.rb +7 -0
  94. data/test/dummy/app/active_record/mang.rb +5 -0
  95. data/test/dummy/app/active_record/only_email_user.rb +7 -0
  96. data/test/dummy/app/active_record/scoped_user.rb +9 -0
  97. data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
  98. data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
  99. data/test/dummy/app/active_record/user.rb +6 -0
  100. data/test/dummy/app/controllers/application_controller.rb +14 -0
  101. data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
  102. data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
  103. data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
  104. data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
  105. data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
  106. data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
  107. data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
  108. data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
  109. data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
  110. data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
  111. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +29 -0
  112. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
  113. data/test/dummy/app/controllers/overrides/passwords_controller.rb +36 -0
  114. data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
  115. data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
  116. data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
  117. data/test/dummy/app/helpers/application_helper.rb +1058 -0
  118. data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
  119. data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
  120. data/test/dummy/app/mongoid/lockable_user.rb +38 -0
  121. data/test/dummy/app/mongoid/mang.rb +46 -0
  122. data/test/dummy/app/mongoid/only_email_user.rb +33 -0
  123. data/test/dummy/app/mongoid/scoped_user.rb +50 -0
  124. data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
  125. data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
  126. data/test/dummy/app/mongoid/user.rb +49 -0
  127. data/test/dummy/app/views/layouts/application.html.erb +12 -0
  128. data/test/dummy/config/application.rb +50 -0
  129. data/test/dummy/config/application.yml.bk +0 -0
  130. data/test/dummy/config/boot.rb +11 -0
  131. data/test/dummy/config/environment.rb +7 -0
  132. data/test/dummy/config/environments/development.rb +36 -0
  133. data/test/dummy/config/environments/production.rb +68 -0
  134. data/test/dummy/config/environments/test.rb +58 -0
  135. data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
  136. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  137. data/test/dummy/config/initializers/devise.rb +290 -0
  138. data/test/dummy/config/initializers/devise_token_auth.rb +55 -0
  139. data/test/dummy/config/initializers/figaro.rb +3 -0
  140. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  141. data/test/dummy/config/initializers/inflections.rb +18 -0
  142. data/test/dummy/config/initializers/mime_types.rb +6 -0
  143. data/test/dummy/config/initializers/omniauth.rb +11 -0
  144. data/test/dummy/config/initializers/session_store.rb +5 -0
  145. data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
  146. data/test/dummy/config/routes.rb +57 -0
  147. data/test/dummy/config/spring.rb +3 -0
  148. data/test/dummy/config.ru +18 -0
  149. data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +58 -0
  150. data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +57 -0
  151. data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
  152. data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
  153. data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +55 -0
  154. data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +56 -0
  155. data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +56 -0
  156. data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +56 -0
  157. data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +56 -0
  158. data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
  159. data/test/dummy/db/schema.rb +198 -0
  160. data/test/dummy/lib/migration_database_helper.rb +43 -0
  161. data/test/dummy/tmp/generators/app/models/mang.rb +9 -0
  162. data/test/dummy/tmp/generators/app/models/user.rb +9 -0
  163. data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +60 -0
  164. data/test/dummy/tmp/generators/config/routes.rb +9 -0
  165. data/test/dummy/tmp/generators/db/migrate/20210305040222_devise_token_auth_create_mangs.rb +49 -0
  166. data/test/dummy/tmp/generators/db/migrate/20210305040222_devise_token_auth_create_users.rb +49 -0
  167. data/test/factories/users.rb +41 -0
  168. data/test/lib/devise_token_auth/blacklist_test.rb +19 -0
  169. data/test/lib/devise_token_auth/rails/custom_routes_test.rb +29 -0
  170. data/test/lib/devise_token_auth/rails/routes_test.rb +87 -0
  171. data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
  172. data/test/lib/devise_token_auth/url_test.rb +26 -0
  173. data/test/lib/generators/devise_token_auth/install_generator_test.rb +217 -0
  174. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +222 -0
  175. data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +25 -0
  176. data/test/models/concerns/mongoid_support_test.rb +31 -0
  177. data/test/models/concerns/tokens_serialization_test.rb +104 -0
  178. data/test/models/confirmable_user_test.rb +35 -0
  179. data/test/models/only_email_user_test.rb +29 -0
  180. data/test/models/user_test.rb +224 -0
  181. data/test/support/controllers/routes.rb +43 -0
  182. data/test/test_helper.rb +134 -0
  183. metadata +502 -0
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:only_email_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
+
19
+ ## Rememberable
20
+ #t.datetime :remember_created_at
21
+
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
27
+
28
+ ## Lockable
29
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
30
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ # t.datetime :locked_at
32
+
33
+ ## User Info
34
+ t.string :name
35
+ t.string :nickname
36
+ t.string :image
37
+ t.string :email
38
+
39
+ ## Tokens
40
+ if json_supported_database?
41
+ t.json :tokens
42
+ else
43
+ t.text :tokens
44
+ end
45
+
46
+ t.timestamps
47
+ end
48
+
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
52
+ # add_index :only_email_users, :confirmation_token, :unique => true
53
+ # add_index :only_email_users, :unlock_token, :unique => true
54
+ end
55
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseTokenAuthCreateUnregisterableUsers < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:unregisterable_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
+ ## Confirmable
24
+ t.string :confirmation_token
25
+ t.datetime :confirmed_at
26
+ t.datetime :confirmation_sent_at
27
+ t.string :unconfirmed_email # Only if using reconfirmable
28
+
29
+ ## Lockable
30
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
31
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
32
+ # t.datetime :locked_at
33
+
34
+ ## User Info
35
+ t.string :name
36
+ t.string :nickname
37
+ t.string :image
38
+ t.string :email
39
+
40
+ ## Tokens
41
+ if json_supported_database?
42
+ t.json :tokens
43
+ else
44
+ t.text :tokens
45
+ end
46
+
47
+ t.timestamps
48
+ end
49
+
50
+ add_index :unregisterable_users, :email
51
+ add_index :unregisterable_users, [:uid, :provider], unique: true
52
+ add_index :unregisterable_users, :reset_password_token, unique: true
53
+ # add_index :unregisterable_users, :confirmation_token, :unique => true
54
+ # add_index :unregisterable_users, :unlock_token, :unique => true
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseTokenAuthCreateUnconfirmableUsers < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:unconfirmable_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
+ ## Confirmable
24
+ # t.string :confirmation_token
25
+ # t.datetime :confirmed_at
26
+ # t.datetime :confirmation_sent_at
27
+ # t.string :unconfirmed_email # Only if using reconfirmable
28
+
29
+ ## Lockable
30
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
31
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
32
+ # t.datetime :locked_at
33
+
34
+ ## User Info
35
+ t.string :name
36
+ t.string :nickname
37
+ t.string :image
38
+ t.string :email
39
+
40
+ ## Tokens
41
+ if json_supported_database?
42
+ t.json :tokens
43
+ else
44
+ t.text :tokens
45
+ end
46
+
47
+ t.timestamps
48
+ end
49
+
50
+ add_index :unconfirmable_users, :email
51
+ add_index :unconfirmable_users, [:uid, :provider], unique: true
52
+ add_index :unconfirmable_users, :reset_password_token, unique: true
53
+ # add_index :nice_users, :confirmation_token, :unique => true
54
+ # add_index :nice_users, :unlock_token, :unique => true
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseTokenAuthCreateScopedUsers < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:scoped_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
+ ## Confirmable
24
+ t.string :confirmation_token
25
+ t.datetime :confirmed_at
26
+ t.datetime :confirmation_sent_at
27
+ t.string :unconfirmed_email # Only if using reconfirmable
28
+
29
+ ## Lockable
30
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
31
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
32
+ # t.datetime :locked_at
33
+
34
+ ## User Info
35
+ t.string :name
36
+ t.string :nickname
37
+ t.string :image
38
+ t.string :email
39
+
40
+ ## Tokens
41
+ if json_supported_database?
42
+ t.json :tokens
43
+ else
44
+ t.text :tokens
45
+ end
46
+
47
+ t.timestamps
48
+ end
49
+
50
+ add_index :scoped_users, :email
51
+ add_index :scoped_users, [:uid, :provider], unique: true
52
+ add_index :scoped_users, :reset_password_token, unique: true
53
+ # add_index :scoped_users, :confirmation_token, :unique => true
54
+ # add_index :scoped_users, :unlock_token, :unique => true
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:lockable_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
+ ## Confirmable
24
+ # t.string :confirmation_token
25
+ # t.datetime :confirmed_at
26
+ # t.datetime :confirmation_sent_at
27
+ # t.string :unconfirmed_email # Only if using reconfirmable
28
+
29
+ ## Lockable
30
+ t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
31
+ t.string :unlock_token # Only if unlock strategy is :email or :both
32
+ t.datetime :locked_at
33
+
34
+ ## User Info
35
+ t.string :name
36
+ t.string :nickname
37
+ t.string :image
38
+ t.string :email
39
+
40
+ ## Tokens
41
+ if json_supported_database?
42
+ t.json :tokens
43
+ else
44
+ t.text :tokens
45
+ end
46
+
47
+ t.timestamps
48
+ end
49
+
50
+ add_index :lockable_users, :email
51
+ add_index :lockable_users, [:uid, :provider], unique: true
52
+ # add_index :lockable_users, :reset_password_token, :unique => true
53
+ # add_index :lockable_users, :confirmation_token, :unique => true
54
+ add_index :lockable_users, :unlock_token, unique: true
55
+ end
56
+ end
@@ -0,0 +1,49 @@
1
+ class DeviseTokenAuthCreateConfirmableUsers < ActiveRecord::Migration[5.2]
2
+ def change
3
+
4
+ create_table(:confirmable_users) do |t|
5
+ ## Required
6
+ t.string :provider, :null => false, :default => "email"
7
+ t.string :uid, :null => false, :default => ""
8
+
9
+ ## Database authenticatable
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
+ ## Confirmable
21
+ t.string :confirmation_token
22
+ t.datetime :confirmed_at
23
+ t.datetime :confirmation_sent_at
24
+ t.string :unconfirmed_email # Only if using reconfirmable
25
+
26
+ ## Lockable
27
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
28
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
29
+ # t.datetime :locked_at
30
+
31
+ ## User Info
32
+ t.string :name
33
+ t.string :nickname
34
+ t.string :image
35
+ t.string :email
36
+
37
+ ## Tokens
38
+ t.text :tokens
39
+
40
+ t.timestamps
41
+ end
42
+
43
+ add_index :confirmable_users, :email, unique: true
44
+ add_index :confirmable_users, [:uid, :provider], unique: true
45
+ add_index :confirmable_users, :reset_password_token, unique: true
46
+ add_index :confirmable_users, :confirmation_token, unique: true
47
+ # add_index :confirmable_users, :unlock_token, unique: true
48
+ end
49
+ end
@@ -0,0 +1,198 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
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
38
+ end
39
+
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
57
+ end
58
+
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
84
+ end
85
+
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
99
+ end
100
+
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
123
+ end
124
+
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
143
+ end
144
+
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
167
+ end
168
+
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
196
+ end
197
+
198
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # polyfill Rails >= 5 versioned migrations
4
+
5
+ unless ActiveRecord::Migration.respond_to?(:[])
6
+ module ActiveRecord
7
+ class Migration
8
+ def self.[](_version)
9
+ self
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ module MigrationDatabaseHelper
16
+ def json_supported_database?
17
+ (postgres? && postgres_correct_version?) || (mysql? && mysql_correct_version?)
18
+ end
19
+
20
+ def postgres?
21
+ database_name == 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
22
+ end
23
+
24
+ def postgres_correct_version?
25
+ database_version > '9.3'
26
+ end
27
+
28
+ def mysql?
29
+ database_name == 'ActiveRecord::ConnectionAdapters::MysqlAdapter'
30
+ end
31
+
32
+ def mysql_correct_version?
33
+ database_version > '5.7.7'
34
+ end
35
+
36
+ def database_name
37
+ ActiveRecord::Base.connection.class.name
38
+ end
39
+
40
+ def database_version
41
+ ActiveRecord::Base.connection.select_value('SELECT VERSION()')
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Mang < ActiveRecord::Base
4
+ # Include default devise modules. Others available are:
5
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
6
+ devise :database_authenticatable, :registerable,
7
+ :recoverable, :rememberable, :validatable
8
+ include DeviseTokenAuth::Concerns::User
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class User < ActiveRecord::Base
4
+ # Include default devise modules. Others available are:
5
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
6
+ devise :database_authenticatable, :registerable,
7
+ :recoverable, :rememberable, :validatable
8
+ include DeviseTokenAuth::Concerns::User
9
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ DeviseTokenAuth.setup do |config|
4
+ # By default the authorization headers will change after each request. The
5
+ # client is responsible for keeping track of the changing tokens. Change
6
+ # this to false to prevent the Authorization header from changing after
7
+ # each request.
8
+ # config.change_headers_on_each_request = true
9
+
10
+ # By default, users will need to re-authenticate after 2 weeks. This setting
11
+ # determines how long tokens will remain valid after they are issued.
12
+ # config.token_lifespan = 2.weeks
13
+
14
+ # Limiting the token_cost to just 4 in testing will increase the performance of
15
+ # your test suite dramatically. The possible cost value is within range from 4
16
+ # to 31. It is recommended to not use a value more than 10 in other environments.
17
+ config.token_cost = Rails.env.test? ? 4 : 10
18
+
19
+ # Sets the max number of concurrent devices per user, which is 10 by default.
20
+ # After this limit is reached, the oldest tokens will be removed.
21
+ # config.max_number_of_devices = 10
22
+
23
+ # Sometimes it's necessary to make several requests to the API at the same
24
+ # time. In this case, each request in the batch will need to share the same
25
+ # auth token. This setting determines how far apart the requests can be while
26
+ # still using the same auth token.
27
+ # config.batch_request_buffer_throttle = 5.seconds
28
+
29
+ # This route will be the prefix for all oauth2 redirect callbacks. For
30
+ # example, using the default '/omniauth', the github oauth2 provider will
31
+ # redirect successful authentications to '/omniauth/github/callback'
32
+ # config.omniauth_prefix = "/omniauth"
33
+
34
+ # By default sending current password is not needed for the password update.
35
+ # Uncomment to enforce current_password param to be checked before all
36
+ # attribute updates. Set it to :password if you want it to be checked only if
37
+ # password is updated.
38
+ # config.check_current_password_before_update = :attributes
39
+
40
+ # By default we will use callbacks for single omniauth.
41
+ # It depends on fields like email, provider and uid.
42
+ # config.default_callbacks = true
43
+
44
+ # Makes it possible to change the headers names
45
+ # config.headers_names = {:'access-token' => 'access-token',
46
+ # :'client' => 'client',
47
+ # :'expiry' => 'expiry',
48
+ # :'uid' => 'uid',
49
+ # :'token-type' => 'token-type' }
50
+
51
+ # By default, only Bearer Token authentication is implemented out of the box.
52
+ # If, however, you wish to integrate with legacy Devise authentication, you can
53
+ # do so by enabling this flag. NOTE: This feature is highly experimental!
54
+ # config.enable_standard_devise_support = false
55
+
56
+ # By default DeviseTokenAuth will not send confirmation email, even when including
57
+ # devise confirmable module. If you want to use devise confirmable module and
58
+ # send email, set it to true. (This is a setting for compatibility)
59
+ # config.send_confirmation_email = true
60
+ end
@@ -0,0 +1,9 @@
1
+ Rails.application.routes.draw do
2
+ mount_devise_token_auth_for 'User', at: 'auth'
3
+
4
+ mount_devise_token_auth_for 'Mang', at: 'mangs'
5
+ as :mang do
6
+ # Define routes for Mang within this block.
7
+ end
8
+ patch '/chong', to: 'bong#index'
9
+ end