devise_token_auth_multi_email 0.9.4 → 0.9.5

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -0
  3. data/Rakefile +4 -8
  4. data/app/controllers/devise_token_auth/concerns/resource_finder.rb +2 -9
  5. data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +35 -5
  6. data/app/controllers/devise_token_auth/registrations_controller.rb +24 -18
  7. data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +6 -3
  8. data/lib/devise_token_auth/engine.rb +40 -1
  9. data/lib/devise_token_auth/version.rb +1 -1
  10. data/test/controllers/devise_token_auth/confirmations_controller_test.rb +4 -4
  11. data/test/controllers/devise_token_auth/multi_email_coexistence_test.rb +130 -0
  12. data/test/controllers/devise_token_auth/multi_email_confirmations_controller_test.rb +210 -0
  13. data/test/controllers/devise_token_auth/multi_email_passwords_controller_test.rb +247 -0
  14. data/test/controllers/devise_token_auth/multi_email_registrations_controller_test.rb +137 -0
  15. data/test/controllers/devise_token_auth/multi_email_sessions_controller_test.rb +191 -0
  16. data/test/controllers/devise_token_auth/multi_email_token_validations_controller_test.rb +140 -0
  17. data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +5 -4
  18. data/test/controllers/devise_token_auth/standard_user_registrations_controller_test.rb +165 -0
  19. data/test/coverage/assets/0.13.2/colorbox/loading.gif +0 -0
  20. data/test/coverage/assets/0.13.2/loading.gif +0 -0
  21. data/test/dummy/app/active_record/multi_email_user.rb +45 -0
  22. data/test/dummy/app/active_record/multi_email_user_email.rb +21 -0
  23. data/test/dummy/config/application.rb +6 -1
  24. data/test/dummy/config/initializers/omniauth.rb +15 -1
  25. data/test/dummy/config/routes.rb +8 -0
  26. data/test/dummy/db/migrate/20260401000001_devise_token_auth_create_multi_email_users.rb +49 -0
  27. data/test/dummy/db/migrate/20260401000002_devise_token_auth_create_multi_email_user_emails.rb +29 -0
  28. data/test/dummy/db/schema.rb +81 -41
  29. data/test/dummy/db/test.sqlite3-shm +0 -0
  30. data/test/dummy/tmp/generators/app/controllers/application_controller.rb +6 -0
  31. data/test/dummy/tmp/generators/app/models/{user.rb → azpire/v1/human_resource/user.rb} +1 -1
  32. data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +11 -5
  33. data/test/dummy/tmp/generators/db/migrate/{20210305040222_devise_token_auth_create_users.rb → 20260408021432_devise_token_auth_create_azpire_v1_human_resource_users.rb} +7 -7
  34. data/test/factories/users.rb +1 -0
  35. data/test/lib/devise_token_auth/controllers/helpers_test.rb +402 -0
  36. data/test/lib/devise_token_auth/token_factory_test.rb +18 -18
  37. data/test/lib/generators/devise_token_auth/install_generator_test.rb +60 -0
  38. data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +1 -1
  39. data/test/lib/generators/devise_token_auth/install_mongoid_generator_test.rb +218 -0
  40. data/test/models/multi_email_user_email_test.rb +95 -0
  41. data/test/models/multi_email_user_test.rb +225 -0
  42. data/test/test_helper.rb +21 -11
  43. data/test/validators/devise_token_auth_email_validator_test.rb +114 -0
  44. metadata +58 -27
  45. data/test/dummy/tmp/generators/app/models/mang.rb +0 -9
  46. data/test/dummy/tmp/generators/config/routes.rb +0 -9
  47. data/test/dummy/tmp/generators/db/migrate/20210305040222_devise_token_auth_create_mangs.rb +0 -49
@@ -10,27 +10,26 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2019_09_24_101113) do
14
-
13
+ ActiveRecord::Schema[7.2].define(version: 2026_04_01_000002) do
15
14
  create_table "confirmable_users", force: :cascade do |t|
16
15
  t.string "provider", default: "email", null: false
17
16
  t.string "uid", default: "", null: false
18
17
  t.string "encrypted_password", default: "", null: false
19
18
  t.string "reset_password_token"
20
- t.datetime "reset_password_sent_at"
19
+ t.datetime "reset_password_sent_at", precision: nil
21
20
  t.boolean "allow_password_change", default: false
22
- t.datetime "remember_created_at"
21
+ t.datetime "remember_created_at", precision: nil
23
22
  t.string "confirmation_token"
24
- t.datetime "confirmed_at"
25
- t.datetime "confirmation_sent_at"
23
+ t.datetime "confirmed_at", precision: nil
24
+ t.datetime "confirmation_sent_at", precision: nil
26
25
  t.string "unconfirmed_email"
27
26
  t.string "name"
28
27
  t.string "nickname"
29
28
  t.string "image"
30
29
  t.string "email"
31
30
  t.text "tokens"
32
- t.datetime "created_at", null: false
33
- t.datetime "updated_at", null: false
31
+ t.datetime "created_at", precision: nil, null: false
32
+ t.datetime "updated_at", precision: nil, null: false
34
33
  t.index ["confirmation_token"], name: "index_confirmable_users_on_confirmation_token", unique: true
35
34
  t.index ["email"], name: "index_confirmable_users_on_email", unique: true
36
35
  t.index ["reset_password_token"], name: "index_confirmable_users_on_reset_password_token", unique: true
@@ -43,14 +42,14 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
43
42
  t.string "encrypted_password", default: "", null: false
44
43
  t.integer "failed_attempts", default: 0, null: false
45
44
  t.string "unlock_token"
46
- t.datetime "locked_at"
45
+ t.datetime "locked_at", precision: nil
47
46
  t.string "name"
48
47
  t.string "nickname"
49
48
  t.string "image"
50
49
  t.string "email"
51
50
  t.text "tokens"
52
- t.datetime "created_at"
53
- t.datetime "updated_at"
51
+ t.datetime "created_at", precision: nil
52
+ t.datetime "updated_at", precision: nil
54
53
  t.index ["email"], name: "index_lockable_users_on_email"
55
54
  t.index ["uid", "provider"], name: "index_lockable_users_on_uid_and_provider", unique: true
56
55
  t.index ["unlock_token"], name: "index_lockable_users_on_unlock_token", unique: true
@@ -60,13 +59,13 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
60
59
  t.string "email"
61
60
  t.string "encrypted_password", default: "", null: false
62
61
  t.string "reset_password_token"
63
- t.datetime "reset_password_sent_at"
62
+ t.datetime "reset_password_sent_at", precision: nil
64
63
  t.string "reset_password_redirect_url"
65
64
  t.boolean "allow_password_change", default: false
66
- t.datetime "remember_created_at"
65
+ t.datetime "remember_created_at", precision: nil
67
66
  t.string "confirmation_token"
68
- t.datetime "confirmed_at"
69
- t.datetime "confirmation_sent_at"
67
+ t.datetime "confirmed_at", precision: nil
68
+ t.datetime "confirmation_sent_at", precision: nil
70
69
  t.string "unconfirmed_email"
71
70
  t.string "name"
72
71
  t.string "nickname"
@@ -74,8 +73,8 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
74
73
  t.string "provider"
75
74
  t.string "uid", default: "", null: false
76
75
  t.text "tokens"
77
- t.datetime "created_at"
78
- t.datetime "updated_at"
76
+ t.datetime "created_at", precision: nil
77
+ t.datetime "updated_at", precision: nil
79
78
  t.string "favorite_color"
80
79
  t.index ["confirmation_token"], name: "index_mangs_on_confirmation_token", unique: true
81
80
  t.index ["email"], name: "index_mangs_on_email"
@@ -83,6 +82,46 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
83
82
  t.index ["uid", "provider"], name: "index_mangs_on_uid_and_provider", unique: true
84
83
  end
85
84
 
85
+ create_table "multi_email_user_emails", force: :cascade do |t|
86
+ t.bigint "multi_email_user_id", null: false
87
+ t.string "email", null: false
88
+ t.boolean "primary", default: false, null: false
89
+ t.string "confirmation_token"
90
+ t.datetime "confirmed_at"
91
+ t.datetime "confirmation_sent_at"
92
+ t.string "unconfirmed_email"
93
+ t.datetime "created_at", null: false
94
+ t.datetime "updated_at", null: false
95
+ t.index ["confirmation_token"], name: "index_multi_email_user_emails_on_confirmation_token", unique: true
96
+ t.index ["email"], name: "index_multi_email_user_emails_on_email", unique: true
97
+ t.index ["multi_email_user_id", "primary"], name: "index_multi_email_user_emails_on_user_and_primary"
98
+ t.index ["multi_email_user_id"], name: "index_multi_email_user_emails_on_multi_email_user_id"
99
+ end
100
+
101
+ create_table "multi_email_users", force: :cascade do |t|
102
+ t.string "encrypted_password", default: "", null: false
103
+ t.string "reset_password_token"
104
+ t.datetime "reset_password_sent_at"
105
+ t.string "reset_password_redirect_url"
106
+ t.boolean "allow_password_change", default: false
107
+ t.datetime "remember_created_at"
108
+ t.string "confirmation_token"
109
+ t.datetime "confirmed_at"
110
+ t.datetime "confirmation_sent_at"
111
+ t.string "unconfirmed_email"
112
+ t.string "name"
113
+ t.string "nickname"
114
+ t.string "image"
115
+ t.string "provider"
116
+ t.string "uid", default: "", null: false
117
+ t.text "tokens"
118
+ t.datetime "created_at", null: false
119
+ t.datetime "updated_at", null: false
120
+ t.index ["confirmation_token"], name: "index_multi_email_users_on_confirmation_token", unique: true
121
+ t.index ["reset_password_token"], name: "index_multi_email_users_on_reset_password_token", unique: true
122
+ t.index ["uid", "provider"], name: "index_multi_email_users_on_uid_and_provider", unique: true
123
+ end
124
+
86
125
  create_table "only_email_users", force: :cascade do |t|
87
126
  t.string "provider", null: false
88
127
  t.string "uid", default: "", null: false
@@ -92,8 +131,8 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
92
131
  t.string "image"
93
132
  t.string "email"
94
133
  t.text "tokens"
95
- t.datetime "created_at"
96
- t.datetime "updated_at"
134
+ t.datetime "created_at", precision: nil
135
+ t.datetime "updated_at", precision: nil
97
136
  t.index ["email"], name: "index_only_email_users_on_email"
98
137
  t.index ["uid", "provider"], name: "index_only_email_users_on_uid_and_provider", unique: true
99
138
  end
@@ -103,20 +142,20 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
103
142
  t.string "uid", default: "", null: false
104
143
  t.string "encrypted_password", default: "", null: false
105
144
  t.string "reset_password_token"
106
- t.datetime "reset_password_sent_at"
145
+ t.datetime "reset_password_sent_at", precision: nil
107
146
  t.boolean "allow_password_change", default: false
108
- t.datetime "remember_created_at"
147
+ t.datetime "remember_created_at", precision: nil
109
148
  t.string "confirmation_token"
110
- t.datetime "confirmed_at"
111
- t.datetime "confirmation_sent_at"
149
+ t.datetime "confirmed_at", precision: nil
150
+ t.datetime "confirmation_sent_at", precision: nil
112
151
  t.string "unconfirmed_email"
113
152
  t.string "name"
114
153
  t.string "nickname"
115
154
  t.string "image"
116
155
  t.string "email"
117
156
  t.text "tokens"
118
- t.datetime "created_at"
119
- t.datetime "updated_at"
157
+ t.datetime "created_at", precision: nil
158
+ t.datetime "updated_at", precision: nil
120
159
  t.index ["email"], name: "index_scoped_users_on_email"
121
160
  t.index ["reset_password_token"], name: "index_scoped_users_on_reset_password_token", unique: true
122
161
  t.index ["uid", "provider"], name: "index_scoped_users_on_uid_and_provider", unique: true
@@ -127,16 +166,16 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
127
166
  t.string "uid", default: "", null: false
128
167
  t.string "encrypted_password", default: "", null: false
129
168
  t.string "reset_password_token"
130
- t.datetime "reset_password_sent_at"
169
+ t.datetime "reset_password_sent_at", precision: nil
131
170
  t.boolean "allow_password_change", default: false
132
- t.datetime "remember_created_at"
171
+ t.datetime "remember_created_at", precision: nil
133
172
  t.string "name"
134
173
  t.string "nickname"
135
174
  t.string "image"
136
175
  t.string "email"
137
176
  t.text "tokens"
138
- t.datetime "created_at"
139
- t.datetime "updated_at"
177
+ t.datetime "created_at", precision: nil
178
+ t.datetime "updated_at", precision: nil
140
179
  t.index ["email"], name: "index_unconfirmable_users_on_email"
141
180
  t.index ["reset_password_token"], name: "index_unconfirmable_users_on_reset_password_token", unique: true
142
181
  t.index ["uid", "provider"], name: "index_unconfirmable_users_on_uid_and_provider", unique: true
@@ -147,20 +186,20 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
147
186
  t.string "uid", default: "", null: false
148
187
  t.string "encrypted_password", default: "", null: false
149
188
  t.string "reset_password_token"
150
- t.datetime "reset_password_sent_at"
189
+ t.datetime "reset_password_sent_at", precision: nil
151
190
  t.boolean "allow_password_change", default: false
152
- t.datetime "remember_created_at"
191
+ t.datetime "remember_created_at", precision: nil
153
192
  t.string "confirmation_token"
154
- t.datetime "confirmed_at"
155
- t.datetime "confirmation_sent_at"
193
+ t.datetime "confirmed_at", precision: nil
194
+ t.datetime "confirmation_sent_at", precision: nil
156
195
  t.string "unconfirmed_email"
157
196
  t.string "name"
158
197
  t.string "nickname"
159
198
  t.string "image"
160
199
  t.string "email"
161
200
  t.text "tokens"
162
- t.datetime "created_at"
163
- t.datetime "updated_at"
201
+ t.datetime "created_at", precision: nil
202
+ t.datetime "updated_at", precision: nil
164
203
  t.index ["email"], name: "index_unregisterable_users_on_email"
165
204
  t.index ["reset_password_token"], name: "index_unregisterable_users_on_reset_password_token", unique: true
166
205
  t.index ["uid", "provider"], name: "index_unregisterable_users_on_uid_and_provider", unique: true
@@ -170,13 +209,13 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
170
209
  t.string "email"
171
210
  t.string "encrypted_password", default: "", null: false
172
211
  t.string "reset_password_token"
173
- t.datetime "reset_password_sent_at"
212
+ t.datetime "reset_password_sent_at", precision: nil
174
213
  t.string "reset_password_redirect_url"
175
214
  t.boolean "allow_password_change", default: false
176
- t.datetime "remember_created_at"
215
+ t.datetime "remember_created_at", precision: nil
177
216
  t.string "confirmation_token"
178
- t.datetime "confirmed_at"
179
- t.datetime "confirmation_sent_at"
217
+ t.datetime "confirmed_at", precision: nil
218
+ t.datetime "confirmation_sent_at", precision: nil
180
219
  t.string "unconfirmed_email"
181
220
  t.string "name"
182
221
  t.string "nickname"
@@ -184,8 +223,8 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
184
223
  t.string "provider"
185
224
  t.string "uid", default: "", null: false
186
225
  t.text "tokens"
187
- t.datetime "created_at"
188
- t.datetime "updated_at"
226
+ t.datetime "created_at", precision: nil
227
+ t.datetime "updated_at", precision: nil
189
228
  t.integer "operating_thetan"
190
229
  t.string "favorite_color"
191
230
  t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
@@ -195,4 +234,5 @@ ActiveRecord::Schema.define(version: 2019_09_24_101113) do
195
234
  t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
196
235
  end
197
236
 
237
+ add_foreign_key "multi_email_user_emails", "multi_email_users"
198
238
  end
Binary file
@@ -0,0 +1,6 @@
1
+ class ApplicationController < ActionController::Base
2
+ include DeviseTokenAuth::Concerns::SetUserByToken
3
+ def whatever
4
+ 'whatever'
5
+ end
6
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class User < ActiveRecord::Base
3
+ class Azpire::V1::HumanResource::User < ActiveRecord::Base
4
4
  # Include default devise modules. Others available are:
5
5
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
6
6
  devise :database_authenticatable, :registerable,
@@ -42,11 +42,17 @@ DeviseTokenAuth.setup do |config|
42
42
  # config.default_callbacks = true
43
43
 
44
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' }
45
+ # config.headers_names = {
46
+ # :'authorization' => 'Authorization',
47
+ # :'access-token' => 'access-token',
48
+ # :'client' => 'client',
49
+ # :'expiry' => 'expiry',
50
+ # :'uid' => 'uid',
51
+ # :'token-type' => 'token-type'
52
+ # }
53
+
54
+ # Makes it possible to use custom uid column
55
+ # config.other_uid = "foo"
50
56
 
51
57
  # By default, only Bearer Token authentication is implemented out of the box.
52
58
  # If, however, you wish to integrate with legacy Devise authentication, you can
@@ -1,7 +1,7 @@
1
- class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[6.1]
1
+ class DeviseTokenAuthCreateAzpireV1HumanResourceUsers < ActiveRecord::Migration[7.2]
2
2
  def change
3
3
 
4
- create_table(:users) do |t|
4
+ create_table(:azpire_v1_human_resource_users) do |t|
5
5
  ## Required
6
6
  t.string :provider, :null => false, :default => "email"
7
7
  t.string :uid, :null => false, :default => ""
@@ -40,10 +40,10 @@ class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[6.1]
40
40
  t.timestamps
41
41
  end
42
42
 
43
- add_index :users, :email, unique: true
44
- add_index :users, [:uid, :provider], unique: true
45
- add_index :users, :reset_password_token, unique: true
46
- add_index :users, :confirmation_token, unique: true
47
- # add_index :users, :unlock_token, unique: true
43
+ add_index :azpire_v1_human_resource_users, :email, unique: true
44
+ add_index :azpire_v1_human_resource_users, [:uid, :provider], unique: true
45
+ add_index :azpire_v1_human_resource_users, :reset_password_token, unique: true
46
+ add_index :azpire_v1_human_resource_users, :confirmation_token, unique: true
47
+ # add_index :azpire_v1_human_resource_users, :unlock_token, unique: true
48
48
  end
49
49
  end
@@ -37,5 +37,6 @@ FactoryBot.define do
37
37
  factory :only_email_user, class: 'OnlyEmailUser'
38
38
  factory :scoped_user, class: 'ScopedUser'
39
39
  factory :confirmable_user, class: 'ConfirmableUser'
40
+ factory :multi_email_user, class: 'MultiEmailUser'
40
41
  end
41
42
  end