devise_jwt_auth 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +99 -0
  4. data/Rakefile +42 -0
  5. data/app/controllers/devise_jwt_auth/application_controller.rb +80 -0
  6. data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +44 -0
  7. data/app/controllers/devise_jwt_auth/concerns/set_user_by_jwt_token.rb +111 -0
  8. data/app/controllers/devise_jwt_auth/confirmations_controller.rb +88 -0
  9. data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +291 -0
  10. data/app/controllers/devise_jwt_auth/passwords_controller.rb +217 -0
  11. data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +41 -0
  12. data/app/controllers/devise_jwt_auth/registrations_controller.rb +203 -0
  13. data/app/controllers/devise_jwt_auth/sessions_controller.rb +131 -0
  14. data/app/controllers/devise_jwt_auth/unlocks_controller.rb +99 -0
  15. data/app/models/devise_jwt_auth/concerns/active_record_support.rb +16 -0
  16. data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +27 -0
  17. data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +19 -0
  18. data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +19 -0
  19. data/app/models/devise_jwt_auth/concerns/user.rb +117 -0
  20. data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +28 -0
  21. data/app/validators/devise_jwt_auth_email_validator.rb +23 -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_jwt_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 +57 -0
  29. data/config/locales/es.yml +51 -0
  30. data/config/locales/fr.yml +51 -0
  31. data/config/locales/he.yml +52 -0
  32. data/config/locales/it.yml +48 -0
  33. data/config/locales/ja.yml +48 -0
  34. data/config/locales/ko.yml +51 -0
  35. data/config/locales/nl.yml +32 -0
  36. data/config/locales/pl.yml +50 -0
  37. data/config/locales/pt-BR.yml +48 -0
  38. data/config/locales/pt.yml +50 -0
  39. data/config/locales/ro.yml +48 -0
  40. data/config/locales/ru.yml +52 -0
  41. data/config/locales/sq.yml +48 -0
  42. data/config/locales/sv.yml +52 -0
  43. data/config/locales/uk.yml +61 -0
  44. data/config/locales/vi.yml +52 -0
  45. data/config/locales/zh-CN.yml +48 -0
  46. data/config/locales/zh-HK.yml +50 -0
  47. data/config/locales/zh-TW.yml +50 -0
  48. data/lib/devise_jwt_auth.rb +14 -0
  49. data/lib/devise_jwt_auth/blacklist.rb +2 -0
  50. data/lib/devise_jwt_auth/controllers/helpers.rb +161 -0
  51. data/lib/devise_jwt_auth/controllers/url_helpers.rb +10 -0
  52. data/lib/devise_jwt_auth/engine.rb +96 -0
  53. data/lib/devise_jwt_auth/errors.rb +8 -0
  54. data/lib/devise_jwt_auth/rails/routes.rb +118 -0
  55. data/lib/devise_jwt_auth/token_factory.rb +51 -0
  56. data/lib/devise_jwt_auth/url.rb +44 -0
  57. data/lib/devise_jwt_auth/version.rb +5 -0
  58. data/lib/generators/devise_jwt_auth/USAGE +31 -0
  59. data/lib/generators/devise_jwt_auth/install_generator.rb +91 -0
  60. data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +98 -0
  61. data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +46 -0
  62. data/lib/generators/devise_jwt_auth/install_views_generator.rb +18 -0
  63. data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +74 -0
  64. data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +51 -0
  65. data/lib/generators/devise_jwt_auth/templates/user.rb.erb +9 -0
  66. data/lib/generators/devise_jwt_auth/templates/user_mongoid.rb.erb +56 -0
  67. data/lib/tasks/devise_token_auth_tasks.rake +6 -0
  68. data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
  69. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
  70. data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
  71. data/test/controllers/custom/custom_refresh_token_controller_test.rb +36 -0
  72. data/test/controllers/custom/custom_registrations_controller_test.rb +59 -0
  73. data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
  74. data/test/controllers/demo_group_controller_test.rb +150 -0
  75. data/test/controllers/demo_mang_controller_test.rb +286 -0
  76. data/test/controllers/demo_user_controller_test.rb +650 -0
  77. data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +194 -0
  78. data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +462 -0
  79. data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +881 -0
  80. data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +84 -0
  81. data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +944 -0
  82. data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +510 -0
  83. data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +197 -0
  84. data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
  85. data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
  86. data/test/controllers/overrides/passwords_controller_test.rb +65 -0
  87. data/test/controllers/overrides/refresh_token_controller_test.rb +37 -0
  88. data/test/controllers/overrides/registrations_controller_test.rb +47 -0
  89. data/test/controllers/overrides/sessions_controller_test.rb +35 -0
  90. data/test/dummy/README.rdoc +28 -0
  91. data/test/dummy/app/active_record/confirmable_user.rb +11 -0
  92. data/test/dummy/app/active_record/lockable_user.rb +7 -0
  93. data/test/dummy/app/active_record/mang.rb +5 -0
  94. data/test/dummy/app/active_record/only_email_user.rb +7 -0
  95. data/test/dummy/app/active_record/scoped_user.rb +9 -0
  96. data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
  97. data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
  98. data/test/dummy/app/active_record/user.rb +6 -0
  99. data/test/dummy/app/controllers/application_controller.rb +18 -0
  100. data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
  101. data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
  102. data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
  103. data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
  104. data/test/dummy/app/controllers/custom/refresh_token_controller.rb +20 -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/demo_group_controller.rb +15 -0
  108. data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
  109. data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
  110. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +37 -0
  111. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
  112. data/test/dummy/app/controllers/overrides/passwords_controller.rb +45 -0
  113. data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +22 -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/helpers/application_helper.rb +1058 -0
  117. data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
  118. data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
  119. data/test/dummy/app/mongoid/lockable_user.rb +38 -0
  120. data/test/dummy/app/mongoid/mang.rb +46 -0
  121. data/test/dummy/app/mongoid/only_email_user.rb +33 -0
  122. data/test/dummy/app/mongoid/scoped_user.rb +50 -0
  123. data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
  124. data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
  125. data/test/dummy/app/mongoid/user.rb +49 -0
  126. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  127. data/test/dummy/config.ru +18 -0
  128. data/test/dummy/config/application.rb +48 -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 +46 -0
  133. data/test/dummy/config/environments/production.rb +84 -0
  134. data/test/dummy/config/environments/test.rb +50 -0
  135. data/test/dummy/config/initializers/assets.rb +10 -0
  136. data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
  137. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  138. data/test/dummy/config/initializers/devise.rb +290 -0
  139. data/test/dummy/config/initializers/devise_jwt_auth.rb +55 -0
  140. data/test/dummy/config/initializers/figaro.rb +3 -0
  141. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  142. data/test/dummy/config/initializers/inflections.rb +18 -0
  143. data/test/dummy/config/initializers/mime_types.rb +6 -0
  144. data/test/dummy/config/initializers/omniauth.rb +11 -0
  145. data/test/dummy/config/initializers/session_store.rb +5 -0
  146. data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
  147. data/test/dummy/config/routes.rb +57 -0
  148. data/test/dummy/config/spring.rb +3 -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/user.rb +9 -0
  162. data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +74 -0
  163. data/test/dummy/tmp/generators/config/routes.rb +4 -0
  164. data/test/dummy/tmp/generators/db/migrate/20200206224309_devise_jwt_auth_create_users.rb +51 -0
  165. data/test/factories/users.rb +41 -0
  166. data/test/lib/devise_jwt_auth/blacklist_test.rb +11 -0
  167. data/test/lib/devise_jwt_auth/token_factory_test.rb +115 -0
  168. data/test/lib/devise_jwt_auth/url_test.rb +26 -0
  169. data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +219 -0
  170. data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +224 -0
  171. data/test/lib/generators/devise_jwt_auth/install_views_generator_test.rb +25 -0
  172. data/test/models/concerns/mongoid_support_test.rb +31 -0
  173. data/test/models/concerns/tokens_serialization_test.rb +72 -0
  174. data/test/models/confirmable_user_test.rb +35 -0
  175. data/test/models/only_email_user_test.rb +29 -0
  176. data/test/models/user_test.rb +110 -0
  177. data/test/support/controllers/routes.rb +43 -0
  178. data/test/test_helper.rb +91 -0
  179. metadata +503 -0
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ DeviseJwtAuth.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
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
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")
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Configure sensitive parameters which will be filtered from the log file.
6
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Add new inflection rules using the following format. Inflections
6
+ # are locale specific, and you may define rules for as many different
7
+ # locales as you wish. All of these examples are active by default:
8
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
9
+ # inflect.plural /^(ox)$/i, '\1en'
10
+ # inflect.singular /^(ox)en/i, '\1'
11
+ # inflect.irregular 'person', 'people'
12
+ # inflect.uncountable %w( fish sheep )
13
+ # end
14
+
15
+ # These inflection rules are supported but not enabled by default:
16
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
17
+ # inflect.acronym 'RESTful'
18
+ # end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Add new mime types for use in respond_to blocks:
6
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.middleware.use OmniAuth::Builder do |b|
4
+ provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
5
+ provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
6
+ provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
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'] }
8
+ provider :developer,
9
+ fields: [:first_name, :last_name],
10
+ uid_field: :last_name
11
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # This file contains settings for ActionController::ParamsWrapper which
6
+ # is enabled by default.
7
+
8
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
9
+ ActiveSupport.on_load(:action_controller) do
10
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
11
+ end
12
+
13
+ # To enable root element in JSON for ActiveRecord objects.
14
+ # ActiveSupport.on_load(:active_record) do
15
+ # self.include_root_in_json = true
16
+ # end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ # when using multiple models, controllers will default to the first available
5
+ # devise mapping. routes for subsequent devise mappings will need to defined
6
+ # within a `devise_scope` block
7
+
8
+ # define :users as the first devise mapping:
9
+ mount_devise_jwt_auth_for 'User', at: 'auth'
10
+
11
+ # define :mangs as the second devise mapping. routes using this class will
12
+ # need to be defined within a devise_scope as shown below
13
+ mount_devise_jwt_auth_for 'Mang', at: 'mangs'
14
+
15
+ mount_devise_jwt_auth_for 'OnlyEmailUser', at: 'only_email_auth', skip: [:omniauth_callbacks]
16
+
17
+ mount_devise_jwt_auth_for 'UnregisterableUser', at: 'unregisterable_user_auth', skip: [:registrations]
18
+
19
+ mount_devise_jwt_auth_for 'UnconfirmableUser', at: 'unconfirmable_user_auth'
20
+
21
+ mount_devise_jwt_auth_for 'LockableUser', at: 'lockable_user_auth'
22
+
23
+ mount_devise_jwt_auth_for 'ConfirmableUser', at: 'confirmable_user_auth'
24
+
25
+ # test namespacing
26
+ namespace :api do
27
+ scope :v1 do
28
+ mount_devise_jwt_auth_for 'User', at: 'auth'
29
+ end
30
+ end
31
+
32
+ # test namespacing with not created devise mapping
33
+ namespace :api_v2, defaults: { format: :json } do
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
+ }
43
+ end
44
+
45
+ # this route will authorize visitors using the User class
46
+ get 'demo/members_only', to: 'demo_user#members_only'
47
+ get 'demo/members_only_remove_token', to: 'demo_user#members_only_remove_token'
48
+
49
+ # routes within this block will authorize visitors using the Mang class
50
+ get 'demo/members_only_mang', to: 'demo_mang#members_only'
51
+
52
+ # routes within this block will authorize visitors using the Mang or User class
53
+ get 'demo/members_only_group', to: 'demo_group#members_only'
54
+
55
+ # we need a route for omniauth_callback_controller to redirect to in sameWindow case
56
+ get 'auth_origin', to: 'auth_origin#redirected'
57
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spring.application_root = './test/dummy'
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseJwtAuthCreateUsers < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:users) do |t|
8
+ ## Database authenticatable
9
+ t.string :email
10
+ t.string :encrypted_password, null: false, default: ''
11
+
12
+ ## Recoverable
13
+ t.string :reset_password_token
14
+ t.datetime :reset_password_sent_at
15
+ t.string :reset_password_redirect_url
16
+ t.boolean :allow_password_change, default: false
17
+
18
+ ## Rememberable
19
+ t.datetime :remember_created_at
20
+
21
+ ## Confirmable
22
+ t.string :confirmation_token
23
+ t.datetime :confirmed_at
24
+ t.datetime :confirmation_sent_at
25
+ t.string :unconfirmed_email # Only if using reconfirmable
26
+
27
+ ## Lockable
28
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
29
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
30
+ # t.datetime :locked_at
31
+
32
+ ## User Info
33
+ t.string :name
34
+ t.string :nickname
35
+ t.string :image
36
+
37
+ ## unique oauth id
38
+ t.string :provider
39
+ t.string :uid, null: false, default: ''
40
+
41
+ ## Tokens
42
+ if json_supported_database?
43
+ t.json :tokens
44
+ else
45
+ t.text :tokens
46
+ end
47
+
48
+ t.timestamps
49
+ end
50
+
51
+ add_index :users, :email
52
+ add_index :users, [:uid, :provider], unique: true
53
+ add_index :users, :reset_password_token, unique: true
54
+ add_index :users, :confirmation_token, unique: true
55
+ add_index :users, :nickname, unique: true
56
+ # add_index :users, :unlock_token, :unique => true
57
+ end
58
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseJwtAuthCreateMangs < ActiveRecord::Migration[4.2]
6
+ def change
7
+ create_table(:mangs) do |t|
8
+ ## Database authenticatable
9
+ t.string :email
10
+ t.string :encrypted_password, null: false, default: ''
11
+
12
+ ## Recoverable
13
+ t.string :reset_password_token
14
+ t.datetime :reset_password_sent_at
15
+ t.string :reset_password_redirect_url
16
+ t.boolean :allow_password_change, default: false
17
+
18
+ ## Rememberable
19
+ t.datetime :remember_created_at
20
+
21
+ ## Confirmable
22
+ t.string :confirmation_token
23
+ t.datetime :confirmed_at
24
+ t.datetime :confirmation_sent_at
25
+ t.string :unconfirmed_email # Only if using reconfirmable
26
+
27
+ ## Lockable
28
+ # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
29
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
30
+ # t.datetime :locked_at
31
+
32
+ ## User Info
33
+ t.string :name
34
+ t.string :nickname
35
+ t.string :image
36
+
37
+ ## unique oauth id
38
+ t.string :provider
39
+ t.string :uid, null: false, default: ''
40
+
41
+ ## Tokens
42
+ if json_supported_database?
43
+ t.json :tokens
44
+ else
45
+ t.text :tokens
46
+ end
47
+
48
+ t.timestamps
49
+ end
50
+
51
+ add_index :mangs, :email
52
+ add_index :mangs, [:uid, :provider], unique: true
53
+ add_index :mangs, :reset_password_token, unique: true
54
+ add_index :mangs, :confirmation_token, unique: true
55
+ # add_index :mangs, :unlock_token, :unique => true
56
+ end
57
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddOperatingThetanToUser < ActiveRecord::Migration[4.2]
4
+ def change
5
+ add_column :users, :operating_thetan, :integer
6
+ add_column :users, :favorite_color, :string
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddFavoriteColorToMangs < ActiveRecord::Migration[4.2]
4
+ def change
5
+ add_column :mangs, :favorite_color, :string
6
+ end
7
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ include MigrationDatabaseHelper
4
+
5
+ class DeviseJwtAuthCreateOnlyEmailUsers < 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 DeviseJwtAuthCreateUnregisterableUsers < 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 DeviseJwtAuthCreateUnconfirmableUsers < 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