devise_jwt_auth 0.1.4 → 0.2.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/controllers/devise_jwt_auth/application_controller.rb +11 -22
  4. data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +3 -7
  5. data/app/controllers/devise_jwt_auth/concerns/set_user_by_token.rb +22 -18
  6. data/app/controllers/devise_jwt_auth/confirmations_controller.rb +10 -19
  7. data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +38 -46
  8. data/app/controllers/devise_jwt_auth/passwords_controller.rb +34 -36
  9. data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +4 -1
  10. data/app/controllers/devise_jwt_auth/registrations_controller.rb +40 -21
  11. data/app/controllers/devise_jwt_auth/sessions_controller.rb +21 -21
  12. data/app/controllers/devise_jwt_auth/unlocks_controller.rb +5 -4
  13. data/app/models/devise_jwt_auth/concerns/active_record_support.rb +3 -0
  14. data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +7 -14
  15. data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +3 -0
  16. data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +4 -1
  17. data/app/models/devise_jwt_auth/concerns/user.rb +18 -11
  18. data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +11 -3
  19. data/app/validators/devise_jwt_auth_email_validator.rb +12 -2
  20. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  21. data/lib/devise_jwt_auth/blacklist.rb +3 -1
  22. data/lib/devise_jwt_auth/controllers/url_helpers.rb +1 -2
  23. data/lib/devise_jwt_auth/engine.rb +4 -4
  24. data/lib/devise_jwt_auth/rails/routes.rb +35 -24
  25. data/lib/devise_jwt_auth/token_factory.rb +3 -2
  26. data/lib/devise_jwt_auth/url.rb +2 -4
  27. data/lib/devise_jwt_auth/version.rb +1 -1
  28. data/lib/generators/devise_jwt_auth/USAGE +1 -1
  29. data/lib/generators/devise_jwt_auth/install_generator.rb +7 -6
  30. data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +27 -6
  31. data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +3 -2
  32. data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +6 -7
  33. data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +15 -11
  34. data/lib/generators/devise_jwt_auth/templates/user.rb.erb +2 -2
  35. data/test/controllers/custom/custom_confirmations_controller_test.rb +2 -2
  36. data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +1 -1
  37. data/test/controllers/custom/custom_passwords_controller_test.rb +8 -8
  38. data/test/controllers/custom/custom_refresh_token_controller_test.rb +2 -3
  39. data/test/controllers/custom/custom_registrations_controller_test.rb +2 -2
  40. data/test/controllers/demo_group_controller_test.rb +0 -24
  41. data/test/controllers/demo_mang_controller_test.rb +4 -224
  42. data/test/controllers/demo_user_controller_test.rb +6 -432
  43. data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +5 -5
  44. data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +9 -10
  45. data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +34 -35
  46. data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +8 -12
  47. data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +12 -26
  48. data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +32 -34
  49. data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +2 -2
  50. data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
  51. data/test/controllers/overrides/passwords_controller_test.rb +1 -6
  52. data/test/controllers/overrides/refresh_token_controller_test.rb +1 -2
  53. data/test/controllers/overrides/registrations_controller_test.rb +1 -1
  54. data/test/dummy/app/controllers/custom/refresh_token_controller.rb +2 -1
  55. data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -1
  56. data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -16
  57. data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +4 -4
  58. data/test/dummy/app/controllers/overrides/passwords_controller.rb +4 -16
  59. data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +1 -1
  60. data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
  61. data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
  62. data/test/dummy/app/models/concerns/favorite_color.rb +11 -9
  63. data/test/dummy/config/application.rb +1 -0
  64. data/test/dummy/config/boot.rb +1 -1
  65. data/test/dummy/config/environments/development.rb +2 -2
  66. data/test/dummy/config/environments/test.rb +11 -7
  67. data/test/dummy/config/initializers/devise_jwt_auth.rb +1 -0
  68. data/test/dummy/config/initializers/figaro.rb +1 -1
  69. data/test/dummy/config/initializers/omniauth.rb +2 -2
  70. data/test/dummy/config/routes.rb +10 -8
  71. data/test/dummy/config.ru +2 -2
  72. data/test/dummy/db/migrate/20141222035835_devise_jwt_auth_create_only_email_users.rb +9 -9
  73. data/test/dummy/db/migrate/20190924101113_devise_jwt_auth_create_confirmable_users.rb +6 -5
  74. data/test/dummy/db/schema.rb +170 -170
  75. data/test/dummy/tmp/generators/app/models/user.rb +8 -0
  76. data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +6 -7
  77. data/test/dummy/tmp/generators/db/migrate/{20200210193225_devise_jwt_auth_create_azpire_v1_human_resource_users.rb → 20220123023137_devise_jwt_auth_create_users.rb} +20 -17
  78. data/test/factories/users.rb +5 -3
  79. data/test/lib/devise_jwt_auth/blacklist_test.rb +2 -2
  80. data/test/lib/devise_jwt_auth/token_factory_test.rb +7 -7
  81. data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +3 -20
  82. data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +4 -21
  83. data/test/models/concerns/tokens_serialization_test.rb +68 -68
  84. data/test/models/user_test.rb +0 -38
  85. data/test/support/controllers/routes.rb +7 -5
  86. data/test/test_helper.rb +1 -1
  87. metadata +45 -71
  88. data/test/dummy/tmp/generators/app/models/azpire/v1/human_resource/user.rb +0 -9
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is auto-generated from the current state of the database. Instead
2
4
  # of editing this file, please use the migrations feature of Active Record to
3
5
  # incrementally modify your database, and then regenerate this schema definition.
@@ -10,189 +12,187 @@
10
12
  #
11
13
  # It's strongly recommended that you check this file into your version control system.
12
14
 
13
- ActiveRecord::Schema.define(version: 2019_09_24_101113) do
14
-
15
- create_table "confirmable_users", force: :cascade do |t|
16
- t.string "provider", default: "email", null: false
17
- t.string "uid", default: "", null: false
18
- t.string "encrypted_password", default: "", null: false
19
- t.string "reset_password_token"
20
- t.datetime "reset_password_sent_at"
21
- t.boolean "allow_password_change", default: false
22
- t.datetime "remember_created_at"
23
- t.string "confirmation_token"
24
- t.datetime "confirmed_at"
25
- t.datetime "confirmation_sent_at"
26
- t.string "unconfirmed_email"
27
- t.string "name"
28
- t.string "nickname"
29
- t.string "image"
30
- t.string "email"
31
- t.text "tokens"
32
- t.datetime "created_at", null: false
33
- t.datetime "updated_at", null: false
34
- t.index ["confirmation_token"], name: "index_confirmable_users_on_confirmation_token", unique: true
35
- t.index ["email"], name: "index_confirmable_users_on_email", unique: true
36
- t.index ["reset_password_token"], name: "index_confirmable_users_on_reset_password_token", unique: true
37
- t.index ["uid", "provider"], name: "index_confirmable_users_on_uid_and_provider", unique: true
15
+ ActiveRecord::Schema.define(version: 20_190_924_101_113) do
16
+ create_table 'confirmable_users', force: :cascade do |t|
17
+ t.string 'provider', default: 'email', null: false
18
+ t.string 'uid', default: '', null: false
19
+ t.string 'encrypted_password', default: '', null: false
20
+ t.string 'reset_password_token'
21
+ t.datetime 'reset_password_sent_at'
22
+ t.boolean 'allow_password_change', default: false
23
+ t.datetime 'remember_created_at'
24
+ t.string 'confirmation_token'
25
+ t.datetime 'confirmed_at'
26
+ t.datetime 'confirmation_sent_at'
27
+ t.string 'unconfirmed_email'
28
+ t.string 'name'
29
+ t.string 'nickname'
30
+ t.string 'image'
31
+ t.string 'email'
32
+ t.text 'tokens'
33
+ t.datetime 'created_at', null: false
34
+ t.datetime 'updated_at', null: false
35
+ t.index ['confirmation_token'], name: 'index_confirmable_users_on_confirmation_token', unique: true
36
+ t.index ['email'], name: 'index_confirmable_users_on_email', unique: true
37
+ t.index ['reset_password_token'], name: 'index_confirmable_users_on_reset_password_token', unique: true
38
+ t.index ['uid', 'provider'], name: 'index_confirmable_users_on_uid_and_provider', unique: true
38
39
  end
39
40
 
40
- create_table "lockable_users", force: :cascade do |t|
41
- t.string "provider", null: false
42
- t.string "uid", default: "", null: false
43
- t.string "encrypted_password", default: "", null: false
44
- t.integer "failed_attempts", default: 0, null: false
45
- t.string "unlock_token"
46
- t.datetime "locked_at"
47
- t.string "name"
48
- t.string "nickname"
49
- t.string "image"
50
- t.string "email"
51
- t.text "tokens"
52
- t.datetime "created_at"
53
- t.datetime "updated_at"
54
- t.index ["email"], name: "index_lockable_users_on_email"
55
- t.index ["uid", "provider"], name: "index_lockable_users_on_uid_and_provider", unique: true
56
- t.index ["unlock_token"], name: "index_lockable_users_on_unlock_token", unique: true
41
+ create_table 'lockable_users', force: :cascade do |t|
42
+ t.string 'provider', null: false
43
+ t.string 'uid', default: '', null: false
44
+ t.string 'encrypted_password', default: '', null: false
45
+ t.integer 'failed_attempts', default: 0, null: false
46
+ t.string 'unlock_token'
47
+ t.datetime 'locked_at'
48
+ t.string 'name'
49
+ t.string 'nickname'
50
+ t.string 'image'
51
+ t.string 'email'
52
+ t.text 'tokens'
53
+ t.datetime 'created_at'
54
+ t.datetime 'updated_at'
55
+ t.index ['email'], name: 'index_lockable_users_on_email'
56
+ t.index ['uid', 'provider'], name: 'index_lockable_users_on_uid_and_provider', unique: true
57
+ t.index ['unlock_token'], name: 'index_lockable_users_on_unlock_token', unique: true
57
58
  end
58
59
 
59
- create_table "mangs", force: :cascade do |t|
60
- t.string "email"
61
- t.string "encrypted_password", default: "", null: false
62
- t.string "reset_password_token"
63
- t.datetime "reset_password_sent_at"
64
- t.string "reset_password_redirect_url"
65
- t.boolean "allow_password_change", default: false
66
- t.datetime "remember_created_at"
67
- t.string "confirmation_token"
68
- t.datetime "confirmed_at"
69
- t.datetime "confirmation_sent_at"
70
- t.string "unconfirmed_email"
71
- t.string "name"
72
- t.string "nickname"
73
- t.string "image"
74
- t.string "provider"
75
- t.string "uid", default: "", null: false
76
- t.text "tokens"
77
- t.datetime "created_at"
78
- t.datetime "updated_at"
79
- t.string "favorite_color"
80
- t.index ["confirmation_token"], name: "index_mangs_on_confirmation_token", unique: true
81
- t.index ["email"], name: "index_mangs_on_email"
82
- t.index ["reset_password_token"], name: "index_mangs_on_reset_password_token", unique: true
83
- t.index ["uid", "provider"], name: "index_mangs_on_uid_and_provider", unique: true
60
+ create_table 'mangs', force: :cascade do |t|
61
+ t.string 'email'
62
+ t.string 'encrypted_password', default: '', null: false
63
+ t.string 'reset_password_token'
64
+ t.datetime 'reset_password_sent_at'
65
+ t.string 'reset_password_redirect_url'
66
+ t.boolean 'allow_password_change', default: false
67
+ t.datetime 'remember_created_at'
68
+ t.string 'confirmation_token'
69
+ t.datetime 'confirmed_at'
70
+ t.datetime 'confirmation_sent_at'
71
+ t.string 'unconfirmed_email'
72
+ t.string 'name'
73
+ t.string 'nickname'
74
+ t.string 'image'
75
+ t.string 'provider'
76
+ t.string 'uid', default: '', null: false
77
+ t.text 'tokens'
78
+ t.datetime 'created_at'
79
+ t.datetime 'updated_at'
80
+ t.string 'favorite_color'
81
+ t.index ['confirmation_token'], name: 'index_mangs_on_confirmation_token', unique: true
82
+ t.index ['email'], name: 'index_mangs_on_email'
83
+ t.index ['reset_password_token'], name: 'index_mangs_on_reset_password_token', unique: true
84
+ t.index ['uid', 'provider'], name: 'index_mangs_on_uid_and_provider', unique: true
84
85
  end
85
86
 
86
- create_table "only_email_users", force: :cascade do |t|
87
- t.string "provider", null: false
88
- t.string "uid", default: "", null: false
89
- t.string "encrypted_password", default: "", null: false
90
- t.string "name"
91
- t.string "nickname"
92
- t.string "image"
93
- t.string "email"
94
- t.text "tokens"
95
- t.datetime "created_at"
96
- t.datetime "updated_at"
97
- t.index ["email"], name: "index_only_email_users_on_email"
98
- t.index ["uid", "provider"], name: "index_only_email_users_on_uid_and_provider", unique: true
87
+ create_table 'only_email_users', force: :cascade do |t|
88
+ t.string 'provider', null: false
89
+ t.string 'uid', default: '', null: false
90
+ t.string 'encrypted_password', default: '', null: false
91
+ t.string 'name'
92
+ t.string 'nickname'
93
+ t.string 'image'
94
+ t.string 'email'
95
+ t.text 'tokens'
96
+ t.datetime 'created_at'
97
+ t.datetime 'updated_at'
98
+ t.index ['email'], name: 'index_only_email_users_on_email'
99
+ t.index ['uid', 'provider'], name: 'index_only_email_users_on_uid_and_provider', unique: true
99
100
  end
100
101
 
101
- create_table "scoped_users", force: :cascade do |t|
102
- t.string "provider", null: false
103
- t.string "uid", default: "", null: false
104
- t.string "encrypted_password", default: "", null: false
105
- t.string "reset_password_token"
106
- t.datetime "reset_password_sent_at"
107
- t.boolean "allow_password_change", default: false
108
- t.datetime "remember_created_at"
109
- t.string "confirmation_token"
110
- t.datetime "confirmed_at"
111
- t.datetime "confirmation_sent_at"
112
- t.string "unconfirmed_email"
113
- t.string "name"
114
- t.string "nickname"
115
- t.string "image"
116
- t.string "email"
117
- t.text "tokens"
118
- t.datetime "created_at"
119
- t.datetime "updated_at"
120
- t.index ["email"], name: "index_scoped_users_on_email"
121
- t.index ["reset_password_token"], name: "index_scoped_users_on_reset_password_token", unique: true
122
- t.index ["uid", "provider"], name: "index_scoped_users_on_uid_and_provider", unique: true
102
+ create_table 'scoped_users', force: :cascade do |t|
103
+ t.string 'provider', null: false
104
+ t.string 'uid', default: '', null: false
105
+ t.string 'encrypted_password', default: '', null: false
106
+ t.string 'reset_password_token'
107
+ t.datetime 'reset_password_sent_at'
108
+ t.boolean 'allow_password_change', default: false
109
+ t.datetime 'remember_created_at'
110
+ t.string 'confirmation_token'
111
+ t.datetime 'confirmed_at'
112
+ t.datetime 'confirmation_sent_at'
113
+ t.string 'unconfirmed_email'
114
+ t.string 'name'
115
+ t.string 'nickname'
116
+ t.string 'image'
117
+ t.string 'email'
118
+ t.text 'tokens'
119
+ t.datetime 'created_at'
120
+ t.datetime 'updated_at'
121
+ t.index ['email'], name: 'index_scoped_users_on_email'
122
+ t.index ['reset_password_token'], name: 'index_scoped_users_on_reset_password_token', unique: true
123
+ t.index ['uid', 'provider'], name: 'index_scoped_users_on_uid_and_provider', unique: true
123
124
  end
124
125
 
125
- create_table "unconfirmable_users", force: :cascade do |t|
126
- t.string "provider", null: false
127
- t.string "uid", default: "", null: false
128
- t.string "encrypted_password", default: "", null: false
129
- t.string "reset_password_token"
130
- t.datetime "reset_password_sent_at"
131
- t.boolean "allow_password_change", default: false
132
- t.datetime "remember_created_at"
133
- t.string "name"
134
- t.string "nickname"
135
- t.string "image"
136
- t.string "email"
137
- t.text "tokens"
138
- t.datetime "created_at"
139
- t.datetime "updated_at"
140
- t.index ["email"], name: "index_unconfirmable_users_on_email"
141
- t.index ["reset_password_token"], name: "index_unconfirmable_users_on_reset_password_token", unique: true
142
- t.index ["uid", "provider"], name: "index_unconfirmable_users_on_uid_and_provider", unique: true
126
+ create_table 'unconfirmable_users', force: :cascade do |t|
127
+ t.string 'provider', null: false
128
+ t.string 'uid', default: '', null: false
129
+ t.string 'encrypted_password', default: '', null: false
130
+ t.string 'reset_password_token'
131
+ t.datetime 'reset_password_sent_at'
132
+ t.boolean 'allow_password_change', default: false
133
+ t.datetime 'remember_created_at'
134
+ t.string 'name'
135
+ t.string 'nickname'
136
+ t.string 'image'
137
+ t.string 'email'
138
+ t.text 'tokens'
139
+ t.datetime 'created_at'
140
+ t.datetime 'updated_at'
141
+ t.index ['email'], name: 'index_unconfirmable_users_on_email'
142
+ t.index ['reset_password_token'], name: 'index_unconfirmable_users_on_reset_password_token', unique: true
143
+ t.index ['uid', 'provider'], name: 'index_unconfirmable_users_on_uid_and_provider', unique: true
143
144
  end
144
145
 
145
- create_table "unregisterable_users", force: :cascade do |t|
146
- t.string "provider", null: false
147
- t.string "uid", default: "", null: false
148
- t.string "encrypted_password", default: "", null: false
149
- t.string "reset_password_token"
150
- t.datetime "reset_password_sent_at"
151
- t.boolean "allow_password_change", default: false
152
- t.datetime "remember_created_at"
153
- t.string "confirmation_token"
154
- t.datetime "confirmed_at"
155
- t.datetime "confirmation_sent_at"
156
- t.string "unconfirmed_email"
157
- t.string "name"
158
- t.string "nickname"
159
- t.string "image"
160
- t.string "email"
161
- t.text "tokens"
162
- t.datetime "created_at"
163
- t.datetime "updated_at"
164
- t.index ["email"], name: "index_unregisterable_users_on_email"
165
- t.index ["reset_password_token"], name: "index_unregisterable_users_on_reset_password_token", unique: true
166
- t.index ["uid", "provider"], name: "index_unregisterable_users_on_uid_and_provider", unique: true
146
+ create_table 'unregisterable_users', force: :cascade do |t|
147
+ t.string 'provider', null: false
148
+ t.string 'uid', default: '', null: false
149
+ t.string 'encrypted_password', default: '', null: false
150
+ t.string 'reset_password_token'
151
+ t.datetime 'reset_password_sent_at'
152
+ t.boolean 'allow_password_change', default: false
153
+ t.datetime 'remember_created_at'
154
+ t.string 'confirmation_token'
155
+ t.datetime 'confirmed_at'
156
+ t.datetime 'confirmation_sent_at'
157
+ t.string 'unconfirmed_email'
158
+ t.string 'name'
159
+ t.string 'nickname'
160
+ t.string 'image'
161
+ t.string 'email'
162
+ t.text 'tokens'
163
+ t.datetime 'created_at'
164
+ t.datetime 'updated_at'
165
+ t.index ['email'], name: 'index_unregisterable_users_on_email'
166
+ t.index ['reset_password_token'], name: 'index_unregisterable_users_on_reset_password_token', unique: true
167
+ t.index ['uid', 'provider'], name: 'index_unregisterable_users_on_uid_and_provider', unique: true
167
168
  end
168
169
 
169
- create_table "users", force: :cascade do |t|
170
- t.string "email"
171
- t.string "encrypted_password", default: "", null: false
172
- t.string "reset_password_token"
173
- t.datetime "reset_password_sent_at"
174
- t.string "reset_password_redirect_url"
175
- t.boolean "allow_password_change", default: false
176
- t.datetime "remember_created_at"
177
- t.string "confirmation_token"
178
- t.datetime "confirmed_at"
179
- t.datetime "confirmation_sent_at"
180
- t.string "unconfirmed_email"
181
- t.string "name"
182
- t.string "nickname"
183
- t.string "image"
184
- t.string "provider"
185
- t.string "uid", default: "", null: false
186
- t.text "tokens"
187
- t.datetime "created_at"
188
- t.datetime "updated_at"
189
- t.integer "operating_thetan"
190
- t.string "favorite_color"
191
- t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
192
- t.index ["email"], name: "index_users_on_email"
193
- t.index ["nickname"], name: "index_users_on_nickname", unique: true
194
- t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
195
- t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
170
+ create_table 'users', force: :cascade do |t|
171
+ t.string 'email'
172
+ t.string 'encrypted_password', default: '', null: false
173
+ t.string 'reset_password_token'
174
+ t.datetime 'reset_password_sent_at'
175
+ t.string 'reset_password_redirect_url'
176
+ t.boolean 'allow_password_change', default: false
177
+ t.datetime 'remember_created_at'
178
+ t.string 'confirmation_token'
179
+ t.datetime 'confirmed_at'
180
+ t.datetime 'confirmation_sent_at'
181
+ t.string 'unconfirmed_email'
182
+ t.string 'name'
183
+ t.string 'nickname'
184
+ t.string 'image'
185
+ t.string 'provider'
186
+ t.string 'uid', default: '', null: false
187
+ t.text 'tokens'
188
+ t.datetime 'created_at'
189
+ t.datetime 'updated_at'
190
+ t.integer 'operating_thetan'
191
+ t.string 'favorite_color'
192
+ t.index ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true
193
+ t.index ['email'], name: 'index_users_on_email'
194
+ t.index ['nickname'], name: 'index_users_on_nickname', unique: true
195
+ t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
196
+ t.index ['uid', 'provider'], name: 'index_users_on_uid_and_provider', unique: true
196
197
  end
197
-
198
198
  end
@@ -0,0 +1,8 @@
1
+ class User < ActiveRecord::Base
2
+ # Include default devise modules.
3
+ devise :database_authenticatable, :registerable,
4
+ :recoverable, :rememberable, :trackable, :validatable,
5
+ :confirmable, :omniauthable
6
+ include DeviseJwtAuth::Concerns::User
7
+ def whatever; puts 'whatever'; end
8
+ end
@@ -6,7 +6,7 @@ DeviseJwtAuth.setup do |config|
6
6
  # use the HTTP only refresh cookie that is sent during the authentication
7
7
  # process and make refresh token requests.
8
8
  # config.send_new_access_token_on_each_request = false
9
-
9
+
10
10
  # By default, refresh token HTTP Only cookies last for 2 weeks. These tokens
11
11
  # are used for requesting shorter-lived acccess tokens.
12
12
  # config.refresh_token_lifespan = 2.weeks
@@ -29,13 +29,13 @@ DeviseJwtAuth.setup do |config|
29
29
  # config.access_token_name = 'access-token'
30
30
 
31
31
  # This is the refresh token encryption key. You should set this in an
32
- # environment variable or secret key base that isn't store in a repository.
32
+ # environment variable or secret key base that isn't stored in a repository.
33
33
  # Also, its a good idea to NOT use the same key for access tokens.
34
34
  config.refresh_token_encryption_key = 'your-refresh-token-secret-key-here'
35
-
36
- # This is the refresh token encryption key. You should set this in an
37
- # environment variable or secret key base that isn't store in a repository.
38
- # Also, its a good idea to NOT use the same key for access tokens.
35
+
36
+ # This is the access token encryption key. You should set this in an
37
+ # environment variable or secret key base that isn't stored in a repository.
38
+ # Also, its a good idea to NOT use the same key for refresh tokens.
39
39
  config.access_token_encryption_key = 'your-access-token-secret-key-here'
40
40
 
41
41
  # This route will be the prefix for all oauth2 redirect callbacks. For
@@ -70,5 +70,4 @@ DeviseJwtAuth.setup do |config|
70
70
  # config.update_token_version_after_password_reset = true
71
71
  # config.bypass_sign_in = true
72
72
  # config.require_client_password_reset_token = false
73
-
74
73
  end
@@ -1,13 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class DeviseJwtAuthCreateAzpireV1HumanResourceUsers < ActiveRecord::Migration[6.0]
3
+ class DeviseJwtAuthCreateUsers < ActiveRecord::Migration[6.1]
4
4
  def change
5
-
6
- create_table(:azpire_v1_human_resource_users) do |t|
5
+ create_table(:users) do |t|
7
6
  ## Required
8
7
  t.string :provider, null: false, default: 'email'
9
8
  t.string :uid, null: false, default: ''
10
9
 
10
+ ## User Info
11
+ t.string :name
12
+ t.string :nickname
13
+ t.string :image
14
+ t.string :email
15
+
11
16
  ## Database authenticatable
12
17
  t.string :encrypted_password, null: false, default: ''
13
18
 
@@ -19,6 +24,13 @@ class DeviseJwtAuthCreateAzpireV1HumanResourceUsers < ActiveRecord::Migration[6.
19
24
  ## Rememberable
20
25
  t.datetime :remember_created_at
21
26
 
27
+ ## Trackable
28
+ # t.integer :sign_in_count, default: 0, null: false
29
+ # t.datetime :current_sign_in_at
30
+ # t.datetime :last_sign_in_at
31
+ # t.string :current_sign_in_ip
32
+ # t.string :last_sign_in_ip
33
+
22
34
  ## Confirmable
23
35
  t.string :confirmation_token
24
36
  t.datetime :confirmed_at
@@ -30,22 +42,13 @@ class DeviseJwtAuthCreateAzpireV1HumanResourceUsers < ActiveRecord::Migration[6.
30
42
  # t.string :unlock_token # Only if unlock strategy is :email or :both
31
43
  # t.datetime :locked_at
32
44
 
33
- ## User Info
34
- t.string :name
35
- t.string :nickname
36
- t.string :image
37
- t.string :email
38
-
39
- ## Tokens
40
- t.text :tokens
41
-
42
45
  t.timestamps
43
46
  end
44
47
 
45
- add_index :azpire_v1_human_resource_users, :email, unique: true
46
- add_index :azpire_v1_human_resource_users, [:uid, :provider], unique: true
47
- add_index :azpire_v1_human_resource_users, :reset_password_token, unique: true
48
- add_index :azpire_v1_human_resource_users, :confirmation_token, unique: true
49
- # add_index :azpire_v1_human_resource_users, :unlock_token, unique: true
48
+ add_index :users, :email, unique: true
49
+ add_index :users, [:uid, :provider], unique: true
50
+ add_index :users, :reset_password_token, unique: true
51
+ add_index :users, :confirmation_token, unique: true
52
+ # add_index :users, :unlock_token, unique: true
50
53
  end
51
54
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryBot.define do
2
4
  factory :user do
3
5
  email { Faker::Internet.unique.safe_email }
@@ -13,13 +15,13 @@ FactoryBot.define do
13
15
  end
14
16
 
15
17
  trait :confirmed do
16
- after(:create) { |user| user.confirm }
18
+ after(:create, &:confirm)
17
19
  end
18
20
 
19
21
  # confirmation period is expired
20
22
  trait :unconfirmed do
21
23
  after(:create) do |user, evaluator|
22
- user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day )
24
+ user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day)
23
25
  end
24
26
  end
25
27
 
@@ -29,7 +31,7 @@ FactoryBot.define do
29
31
  end
30
32
 
31
33
  trait :locked do
32
- after(:create) { |user| user.lock_access! }
34
+ after(:create, &:lock_access!)
33
35
  end
34
36
 
35
37
  factory :lockable_user, class: 'LockableUser'
@@ -3,9 +3,9 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class DeviseJwtAuth::BlacklistTest < ActiveSupport::TestCase
6
- describe Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION do
6
+ describe Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION do
7
7
  test 'should include :tokens' do
8
- assert Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION.include?(:tokens)
8
+ assert Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION.include?(:tokens)
9
9
  end
10
10
  end
11
11
  end
@@ -5,15 +5,15 @@ require 'test_helper'
5
5
  class DeviseJwtAuth::TokenFactoryTest < ActiveSupport::TestCase
6
6
  describe 'TokenFactory module' do
7
7
  let(:tf) { DeviseJwtAuth::TokenFactory }
8
- let(:token_regexp) { /^[A-Za-z0-9\-_=]+\.[A-Za-z0-9\-_=]+\.?[A-Za-z0-9\-_.+\/=]*$/ }
9
-
8
+ let(:token_regexp) { %r{^[A-Za-z0-9\-_=]+\.[A-Za-z0-9\-_=]+\.?[A-Za-z0-9\-_.+/=]*$} }
9
+
10
10
  it 'should be defined' do
11
11
  assert_equal(tf.present?, true)
12
12
  assert_kind_of(Module, tf)
13
13
  end
14
-
14
+
15
15
  describe 'interface' do
16
- let(:payload) { { foo: 'test'} }
16
+ let(:payload) { { foo: 'test' } }
17
17
  let(:future_exp) { (Time.zone.now + 1.hour).to_i }
18
18
  let(:past_exp) { (Time.zone.now - 1.hour).to_i }
19
19
 
@@ -44,13 +44,13 @@ class DeviseJwtAuth::TokenFactoryTest < ActiveSupport::TestCase
44
44
  result = tf.decode_refresh_token(token)
45
45
  assert result['exp'] == future_exp
46
46
  end
47
-
47
+
48
48
  it 'invalidates expired token' do
49
49
  token = tf.create_refresh_token(payload.merge(exp: past_exp))
50
50
  result = tf.decode_refresh_token(token)
51
51
  assert_nil result['exp']
52
52
  end
53
-
53
+
54
54
  it 'invalidates bogus token' do
55
55
  result = tf.decode_refresh_token('bogus token')
56
56
  assert_empty result
@@ -91,7 +91,7 @@ class DeviseJwtAuth::TokenFactoryTest < ActiveSupport::TestCase
91
91
  result = tf.decode_access_token(token)
92
92
  assert_nil result['exp']
93
93
  end
94
-
94
+
95
95
  it 'invalidates bogus token' do
96
96
  result = tf.decode_access_token('bogus token')
97
97
  assert_empty result
@@ -44,17 +44,6 @@ module DeviseJwtAuth
44
44
  assert_migration 'db/migrate/devise_jwt_auth_create_users.rb'
45
45
  end
46
46
  end
47
-
48
- =begin
49
- test 'add primary key type with rails 5 when specified in rails generator' do
50
- run_generator %w[--primary_key_type=uuid --force]
51
- if Rails::VERSION::MAJOR >= 5
52
- assert_migration 'db/migrate/devise_jwt_auth_create_users.rb', /create_table\(:users, id: :uuid\) do/
53
- else
54
- assert_migration 'db/migrate/devise_jwt_auth_create_users.rb', /create_table\(:users\) do/
55
- end
56
- end
57
- =end
58
47
  end
59
48
  end
60
49
 
@@ -72,15 +61,12 @@ module DeviseJwtAuth
72
61
  case DEVISE_JWT_AUTH_ORM
73
62
  when :active_record
74
63
  # account for rails version 5
75
- active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base'
64
+ active_record_needle = Rails::VERSION::MAJOR == 5 ? 'ApplicationRecord' : 'ActiveRecord::Base'
76
65
 
77
66
  @f = File.open(@fname, 'w') do |f|
78
67
  f.write <<-RUBY
79
68
  class User < #{active_record_needle}
80
-
81
- def whatever
82
- puts 'whatever'
83
- end
69
+ def whatever; puts 'whatever'; end
84
70
  end
85
71
  RUBY
86
72
  end
@@ -88,10 +74,7 @@ module DeviseJwtAuth
88
74
  @f = File.open(@fname, 'w') do |f|
89
75
  f.write <<-'RUBY'
90
76
  class User
91
-
92
- def whatever
93
- puts 'whatever'
94
- end
77
+ def whatever; puts 'whatever'; end
95
78
  end
96
79
  RUBY
97
80
  end