devise_token_auth 0.1.43 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +42 -895
- data/Rakefile +11 -4
- data/app/controllers/devise_token_auth/application_controller.rb +19 -8
- data/app/controllers/devise_token_auth/concerns/resource_finder.rb +26 -12
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +106 -85
- data/app/controllers/devise_token_auth/confirmations_controller.rb +73 -17
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +95 -51
- data/app/controllers/devise_token_auth/passwords_controller.rb +65 -57
- data/app/controllers/devise_token_auth/registrations_controller.rb +61 -61
- data/app/controllers/devise_token_auth/sessions_controller.rb +22 -18
- data/app/controllers/devise_token_auth/token_validations_controller.rb +5 -3
- data/app/controllers/devise_token_auth/unlocks_controller.rb +20 -16
- data/app/models/devise_token_auth/concerns/active_record_support.rb +14 -0
- data/app/models/devise_token_auth/concerns/confirmable_support.rb +28 -0
- data/app/models/devise_token_auth/concerns/mongoid_support.rb +19 -0
- data/app/models/devise_token_auth/concerns/tokens_serialization.rb +31 -0
- data/app/models/devise_token_auth/concerns/user.rb +92 -100
- data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +8 -3
- data/app/validators/{email_validator.rb → devise_token_auth_email_validator.rb} +5 -3
- data/app/views/devise_token_auth/omniauth_external_window.html.erb +1 -1
- data/config/locales/da-DK.yml +11 -9
- data/config/locales/de.yml +2 -0
- data/config/locales/en.yml +10 -0
- data/config/locales/es.yml +2 -0
- data/config/locales/fr.yml +2 -0
- data/config/locales/he.yml +52 -0
- data/config/locales/it.yml +2 -0
- data/config/locales/ja.yml +4 -2
- data/config/locales/ko.yml +51 -0
- data/config/locales/nl.yml +2 -0
- data/config/locales/pl.yml +6 -3
- data/config/locales/pt-BR.yml +2 -0
- data/config/locales/pt.yml +6 -3
- data/config/locales/ro.yml +2 -0
- data/config/locales/ru.yml +2 -0
- data/config/locales/sq.yml +2 -0
- data/config/locales/sv.yml +52 -0
- data/config/locales/uk.yml +2 -0
- data/config/locales/vi.yml +2 -0
- data/config/locales/zh-CN.yml +2 -0
- data/config/locales/zh-HK.yml +2 -0
- data/config/locales/zh-TW.yml +2 -0
- data/lib/devise_token_auth/blacklist.rb +6 -0
- data/lib/devise_token_auth/controllers/helpers.rb +21 -13
- data/lib/devise_token_auth/controllers/url_helpers.rb +2 -0
- data/lib/devise_token_auth/engine.rb +26 -14
- data/lib/devise_token_auth/errors.rb +8 -0
- data/lib/devise_token_auth/rails/routes.rb +37 -30
- data/lib/devise_token_auth/token_factory.rb +126 -0
- data/lib/devise_token_auth/url.rb +11 -4
- data/lib/devise_token_auth/version.rb +3 -1
- data/lib/devise_token_auth.rb +11 -5
- data/lib/generators/devise_token_auth/USAGE +2 -2
- data/lib/generators/devise_token_auth/install_generator.rb +36 -105
- data/lib/generators/devise_token_auth/install_generator_helpers.rb +98 -0
- data/lib/generators/devise_token_auth/install_mongoid_generator.rb +46 -0
- data/lib/generators/devise_token_auth/install_views_generator.rb +7 -5
- data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +12 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +8 -14
- data/lib/generators/devise_token_auth/templates/user.rb.erb +9 -0
- data/lib/generators/devise_token_auth/templates/user_mongoid.rb.erb +56 -0
- data/lib/tasks/devise_token_auth_tasks.rake +2 -0
- data/test/controllers/custom/custom_confirmations_controller_test.rb +5 -1
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +4 -0
- data/test/controllers/custom/custom_passwords_controller_test.rb +6 -2
- data/test/controllers/custom/custom_registrations_controller_test.rb +17 -8
- data/test/controllers/custom/custom_sessions_controller_test.rb +7 -5
- data/test/controllers/custom/custom_token_validations_controller_test.rb +5 -3
- data/test/controllers/demo_group_controller_test.rb +4 -6
- data/test/controllers/demo_mang_controller_test.rb +3 -3
- data/test/controllers/demo_user_controller_test.rb +53 -25
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +159 -25
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +117 -47
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +309 -126
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +65 -23
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +93 -61
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +18 -6
- data/test/controllers/devise_token_auth/unlocks_controller_test.rb +24 -5
- data/test/controllers/overrides/confirmations_controller_test.rb +6 -2
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +5 -1
- data/test/controllers/overrides/passwords_controller_test.rb +27 -29
- data/test/controllers/overrides/registrations_controller_test.rb +33 -27
- data/test/controllers/overrides/sessions_controller_test.rb +6 -4
- data/test/controllers/overrides/token_validations_controller_test.rb +5 -3
- data/test/dummy/app/active_record/confirmable_user.rb +11 -0
- data/test/dummy/app/{models → active_record}/lockable_user.rb +2 -0
- data/test/dummy/app/{models → active_record}/mang.rb +2 -0
- data/test/dummy/app/{models → active_record}/only_email_user.rb +2 -0
- data/test/dummy/app/{models → active_record}/scoped_user.rb +4 -2
- data/test/dummy/app/{models → active_record}/unconfirmable_user.rb +3 -2
- data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
- data/test/dummy/app/active_record/user.rb +6 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/auth_origin_controller.rb +2 -0
- data/test/dummy/app/controllers/custom/confirmations_controller.rb +2 -2
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +2 -0
- data/test/dummy/app/controllers/custom/passwords_controller.rb +3 -4
- data/test/dummy/app/controllers/custom/registrations_controller.rb +3 -3
- data/test/dummy/app/controllers/custom/sessions_controller.rb +3 -3
- data/test/dummy/app/controllers/custom/token_validations_controller.rb +3 -3
- data/test/dummy/app/controllers/demo_group_controller.rb +2 -0
- data/test/dummy/app/controllers/demo_mang_controller.rb +2 -0
- data/test/dummy/app/controllers/demo_user_controller.rb +2 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +8 -6
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +5 -3
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +10 -8
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +5 -3
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +12 -12
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +5 -5
- data/test/dummy/app/helpers/application_helper.rb +1029 -1036
- data/test/dummy/app/models/{user.rb → concerns/favorite_color.rb} +8 -7
- data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
- data/test/dummy/app/mongoid/lockable_user.rb +38 -0
- data/test/dummy/app/mongoid/mang.rb +46 -0
- data/test/dummy/app/mongoid/only_email_user.rb +33 -0
- data/test/dummy/app/mongoid/scoped_user.rb +50 -0
- data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
- data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
- data/test/dummy/app/mongoid/user.rb +49 -0
- data/test/dummy/app/views/layouts/application.html.erb +0 -2
- data/test/dummy/config/application.rb +26 -3
- data/test/dummy/config/boot.rb +8 -2
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/development.rb +5 -13
- data/test/dummy/config/environments/production.rb +2 -16
- data/test/dummy/config/environments/test.rb +3 -1
- data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/test/dummy/config/initializers/devise.rb +287 -0
- data/test/dummy/config/initializers/devise_token_auth.rb +37 -4
- data/test/dummy/config/initializers/figaro.rb +3 -1
- data/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/test/dummy/config/initializers/inflections.rb +2 -0
- data/test/dummy/config/initializers/mime_types.rb +2 -0
- data/test/dummy/config/initializers/omniauth.rb +5 -2
- data/test/dummy/config/initializers/session_store.rb +2 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/test/dummy/config/routes.rb +14 -29
- data/test/dummy/config/spring.rb +2 -0
- data/test/dummy/config.ru +5 -3
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +9 -14
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +8 -13
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +2 -0
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +2 -0
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +6 -11
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +8 -13
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +8 -13
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +8 -13
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +8 -13
- data/test/dummy/{tmp/generators/db/migrate/20171014052631_devise_token_auth_create_users.rb → db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb} +8 -14
- data/test/dummy/db/schema.rb +11 -71
- data/test/dummy/lib/migration_database_helper.rb +15 -1
- data/test/dummy/tmp/generators/app/controllers/application_controller.rb +6 -0
- data/test/dummy/tmp/generators/app/models/azpire/v1/human_resource/user.rb +56 -0
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +12 -0
- data/test/factories/users.rb +41 -0
- data/test/lib/devise_token_auth/blacklist_test.rb +19 -0
- data/test/lib/devise_token_auth/rails/custom_routes_test.rb +29 -0
- data/test/lib/devise_token_auth/rails/routes_test.rb +87 -0
- data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
- data/test/lib/devise_token_auth/url_test.rb +9 -7
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +67 -37
- data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +222 -0
- data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +3 -1
- data/test/models/concerns/mongoid_support_test.rb +31 -0
- data/test/models/concerns/tokens_serialization_test.rb +104 -0
- data/test/models/confirmable_user_test.rb +35 -0
- data/test/models/only_email_user_test.rb +2 -8
- data/test/models/user_test.rb +18 -79
- data/test/support/controllers/routes.rb +43 -0
- data/test/test_helper.rb +83 -26
- metadata +153 -44
- data/config/initializers/devise.rb +0 -196
- data/lib/generators/devise_token_auth/templates/user.rb +0 -7
- data/test/dummy/app/models/evil_user.rb +0 -3
- data/test/dummy/app/models/nice_user.rb +0 -7
- data/test/dummy/app/models/unregisterable_user.rb +0 -7
- data/test/dummy/config/initializers/assets.rb +0 -8
- data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +0 -64
- data/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +0 -61
- data/test/dummy/tmp/generators/app/models/user.rb +0 -11
- data/test/integration/navigation_test.rb +0 -10
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include MigrationDatabaseHelper
|
2
4
|
|
3
5
|
class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
|
4
6
|
def change
|
5
7
|
create_table(:only_email_users) do |t|
|
6
8
|
## Required
|
7
|
-
t.string :provider, :
|
8
|
-
t.string :uid, :
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
9
11
|
|
10
12
|
## Database authenticatable
|
11
|
-
t.string :encrypted_password, :
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
12
14
|
|
13
15
|
## Recoverable
|
14
16
|
#t.string :reset_password_token
|
@@ -17,13 +19,6 @@ class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
|
|
17
19
|
## Rememberable
|
18
20
|
#t.datetime :remember_created_at
|
19
21
|
|
20
|
-
## Trackable
|
21
|
-
#t.integer :sign_in_count, :default => 0, :null => false
|
22
|
-
#t.datetime :current_sign_in_at
|
23
|
-
#t.datetime :last_sign_in_at
|
24
|
-
#t.string :current_sign_in_ip
|
25
|
-
#t.string :last_sign_in_ip
|
26
|
-
|
27
22
|
## Confirmable
|
28
23
|
#t.string :confirmation_token
|
29
24
|
#t.datetime :confirmed_at
|
@@ -52,7 +47,7 @@ class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
|
|
52
47
|
end
|
53
48
|
|
54
49
|
add_index :only_email_users, :email
|
55
|
-
add_index :only_email_users, [:uid, :provider], :
|
50
|
+
add_index :only_email_users, [:uid, :provider], unique: true
|
56
51
|
#add_index :only_email_users, :reset_password_token, :unique => true
|
57
52
|
# add_index :only_email_users, :confirmation_token, :unique => true
|
58
53
|
# add_index :only_email_users, :unlock_token, :unique => true
|
@@ -1,30 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include MigrationDatabaseHelper
|
2
4
|
|
3
5
|
class DeviseTokenAuthCreateUnregisterableUsers < ActiveRecord::Migration[4.2]
|
4
6
|
def change
|
5
7
|
create_table(:unregisterable_users) do |t|
|
6
8
|
## Required
|
7
|
-
t.string :provider, :
|
8
|
-
t.string :uid, :
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
9
11
|
|
10
12
|
## Database authenticatable
|
11
|
-
t.string :encrypted_password, :
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
12
14
|
|
13
15
|
## Recoverable
|
14
16
|
t.string :reset_password_token
|
15
17
|
t.datetime :reset_password_sent_at
|
16
|
-
t.boolean :allow_password_change, :
|
18
|
+
t.boolean :allow_password_change, default: false
|
17
19
|
|
18
20
|
## Rememberable
|
19
21
|
t.datetime :remember_created_at
|
20
22
|
|
21
|
-
## Trackable
|
22
|
-
t.integer :sign_in_count, :default => 0, :null => false
|
23
|
-
t.datetime :current_sign_in_at
|
24
|
-
t.datetime :last_sign_in_at
|
25
|
-
t.string :current_sign_in_ip
|
26
|
-
t.string :last_sign_in_ip
|
27
|
-
|
28
23
|
## Confirmable
|
29
24
|
t.string :confirmation_token
|
30
25
|
t.datetime :confirmed_at
|
@@ -53,8 +48,8 @@ class DeviseTokenAuthCreateUnregisterableUsers < ActiveRecord::Migration[4.2]
|
|
53
48
|
end
|
54
49
|
|
55
50
|
add_index :unregisterable_users, :email
|
56
|
-
add_index :unregisterable_users, [:uid, :provider], :
|
57
|
-
add_index :unregisterable_users, :reset_password_token, :
|
51
|
+
add_index :unregisterable_users, [:uid, :provider], unique: true
|
52
|
+
add_index :unregisterable_users, :reset_password_token, unique: true
|
58
53
|
# add_index :unregisterable_users, :confirmation_token, :unique => true
|
59
54
|
# add_index :unregisterable_users, :unlock_token, :unique => true
|
60
55
|
end
|
@@ -1,30 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include MigrationDatabaseHelper
|
2
4
|
|
3
5
|
class DeviseTokenAuthCreateUnconfirmableUsers < ActiveRecord::Migration[4.2]
|
4
6
|
def change
|
5
7
|
create_table(:unconfirmable_users) do |t|
|
6
8
|
## Required
|
7
|
-
t.string :provider, :
|
8
|
-
t.string :uid, :
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
9
11
|
|
10
12
|
## Database authenticatable
|
11
|
-
t.string :encrypted_password, :
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
12
14
|
|
13
15
|
## Recoverable
|
14
16
|
t.string :reset_password_token
|
15
17
|
t.datetime :reset_password_sent_at
|
16
|
-
t.boolean :allow_password_change, :
|
18
|
+
t.boolean :allow_password_change, default: false
|
17
19
|
|
18
20
|
## Rememberable
|
19
21
|
t.datetime :remember_created_at
|
20
22
|
|
21
|
-
## Trackable
|
22
|
-
t.integer :sign_in_count, :default => 0, :null => false
|
23
|
-
t.datetime :current_sign_in_at
|
24
|
-
t.datetime :last_sign_in_at
|
25
|
-
t.string :current_sign_in_ip
|
26
|
-
t.string :last_sign_in_ip
|
27
|
-
|
28
23
|
## Confirmable
|
29
24
|
# t.string :confirmation_token
|
30
25
|
# t.datetime :confirmed_at
|
@@ -53,8 +48,8 @@ class DeviseTokenAuthCreateUnconfirmableUsers < ActiveRecord::Migration[4.2]
|
|
53
48
|
end
|
54
49
|
|
55
50
|
add_index :unconfirmable_users, :email
|
56
|
-
add_index :unconfirmable_users, [:uid, :provider], :
|
57
|
-
add_index :unconfirmable_users, :reset_password_token, :
|
51
|
+
add_index :unconfirmable_users, [:uid, :provider], unique: true
|
52
|
+
add_index :unconfirmable_users, :reset_password_token, unique: true
|
58
53
|
# add_index :nice_users, :confirmation_token, :unique => true
|
59
54
|
# add_index :nice_users, :unlock_token, :unique => true
|
60
55
|
end
|
@@ -1,30 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include MigrationDatabaseHelper
|
2
4
|
|
3
5
|
class DeviseTokenAuthCreateScopedUsers < ActiveRecord::Migration[4.2]
|
4
6
|
def change
|
5
7
|
create_table(:scoped_users) do |t|
|
6
8
|
## Required
|
7
|
-
t.string :provider, :
|
8
|
-
t.string :uid, :
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
9
11
|
|
10
12
|
## Database authenticatable
|
11
|
-
t.string :encrypted_password, :
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
12
14
|
|
13
15
|
## Recoverable
|
14
16
|
t.string :reset_password_token
|
15
17
|
t.datetime :reset_password_sent_at
|
16
|
-
t.boolean :allow_password_change, :
|
18
|
+
t.boolean :allow_password_change, default: false
|
17
19
|
|
18
20
|
## Rememberable
|
19
21
|
t.datetime :remember_created_at
|
20
22
|
|
21
|
-
## Trackable
|
22
|
-
t.integer :sign_in_count, :default => 0, :null => false
|
23
|
-
t.datetime :current_sign_in_at
|
24
|
-
t.datetime :last_sign_in_at
|
25
|
-
t.string :current_sign_in_ip
|
26
|
-
t.string :last_sign_in_ip
|
27
|
-
|
28
23
|
## Confirmable
|
29
24
|
t.string :confirmation_token
|
30
25
|
t.datetime :confirmed_at
|
@@ -53,8 +48,8 @@ class DeviseTokenAuthCreateScopedUsers < ActiveRecord::Migration[4.2]
|
|
53
48
|
end
|
54
49
|
|
55
50
|
add_index :scoped_users, :email
|
56
|
-
add_index :scoped_users, [:uid, :provider], :
|
57
|
-
add_index :scoped_users, :reset_password_token, :
|
51
|
+
add_index :scoped_users, [:uid, :provider], unique: true
|
52
|
+
add_index :scoped_users, :reset_password_token, unique: true
|
58
53
|
# add_index :scoped_users, :confirmation_token, :unique => true
|
59
54
|
# add_index :scoped_users, :unlock_token, :unique => true
|
60
55
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
include MigrationDatabaseHelper
|
2
4
|
|
3
5
|
class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2]
|
4
6
|
def change
|
5
7
|
create_table(:lockable_users) do |t|
|
6
8
|
## Required
|
7
|
-
t.string :provider, :
|
8
|
-
t.string :uid, :
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
9
11
|
|
10
12
|
## Database authenticatable
|
11
|
-
t.string :encrypted_password, :
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
12
14
|
|
13
15
|
## Recoverable
|
14
16
|
# t.string :reset_password_token
|
@@ -18,13 +20,6 @@ class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2]
|
|
18
20
|
## Rememberable
|
19
21
|
# t.datetime :remember_created_at
|
20
22
|
|
21
|
-
## Trackable
|
22
|
-
# t.integer :sign_in_count, :default => 0, :null => false
|
23
|
-
# t.datetime :current_sign_in_at
|
24
|
-
# t.datetime :last_sign_in_at
|
25
|
-
# t.string :current_sign_in_ip
|
26
|
-
# t.string :last_sign_in_ip
|
27
|
-
|
28
23
|
## Confirmable
|
29
24
|
# t.string :confirmation_token
|
30
25
|
# t.datetime :confirmed_at
|
@@ -32,7 +27,7 @@ class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2]
|
|
32
27
|
# t.string :unconfirmed_email # Only if using reconfirmable
|
33
28
|
|
34
29
|
## Lockable
|
35
|
-
t.integer :failed_attempts, :
|
30
|
+
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
36
31
|
t.string :unlock_token # Only if unlock strategy is :email or :both
|
37
32
|
t.datetime :locked_at
|
38
33
|
|
@@ -53,9 +48,9 @@ class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2]
|
|
53
48
|
end
|
54
49
|
|
55
50
|
add_index :lockable_users, :email
|
56
|
-
add_index :lockable_users, [:uid, :provider], :
|
51
|
+
add_index :lockable_users, [:uid, :provider], unique: true
|
57
52
|
# add_index :lockable_users, :reset_password_token, :unique => true
|
58
53
|
# add_index :lockable_users, :confirmation_token, :unique => true
|
59
|
-
add_index :lockable_users, :unlock_token, :
|
54
|
+
add_index :lockable_users, :unlock_token, unique: true
|
60
55
|
end
|
61
56
|
end
|
@@ -1,6 +1,7 @@
|
|
1
|
-
class
|
1
|
+
class DeviseTokenAuthCreateConfirmableUsers < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
|
-
|
3
|
+
|
4
|
+
create_table(:confirmable_users) do |t|
|
4
5
|
## Required
|
5
6
|
t.string :provider, :null => false, :default => "email"
|
6
7
|
t.string :uid, :null => false, :default => ""
|
@@ -16,13 +17,6 @@ class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[5.1]
|
|
16
17
|
## Rememberable
|
17
18
|
t.datetime :remember_created_at
|
18
19
|
|
19
|
-
## Trackable
|
20
|
-
t.integer :sign_in_count, :default => 0, :null => false
|
21
|
-
t.datetime :current_sign_in_at
|
22
|
-
t.datetime :last_sign_in_at
|
23
|
-
t.string :current_sign_in_ip
|
24
|
-
t.string :last_sign_in_ip
|
25
|
-
|
26
20
|
## Confirmable
|
27
21
|
t.string :confirmation_token
|
28
22
|
t.datetime :confirmed_at
|
@@ -46,10 +40,10 @@ class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[5.1]
|
|
46
40
|
t.timestamps
|
47
41
|
end
|
48
42
|
|
49
|
-
add_index :
|
50
|
-
add_index :
|
51
|
-
add_index :
|
52
|
-
add_index :
|
53
|
-
# add_index :
|
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
|
54
48
|
end
|
55
49
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -10,20 +10,16 @@
|
|
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:
|
13
|
+
ActiveRecord::Schema.define(version: 2019_09_24_101113) do
|
14
14
|
|
15
|
-
create_table "
|
16
|
-
t.string "email"
|
15
|
+
create_table "confirmable_users", force: :cascade do |t|
|
16
|
+
t.string "provider", default: "email", null: false
|
17
|
+
t.string "uid", default: "", null: false
|
17
18
|
t.string "encrypted_password", default: "", null: false
|
18
19
|
t.string "reset_password_token"
|
19
20
|
t.datetime "reset_password_sent_at"
|
20
21
|
t.boolean "allow_password_change", default: false
|
21
22
|
t.datetime "remember_created_at"
|
22
|
-
t.integer "sign_in_count", default: 0, null: false
|
23
|
-
t.datetime "current_sign_in_at"
|
24
|
-
t.datetime "last_sign_in_at"
|
25
|
-
t.string "current_sign_in_ip"
|
26
|
-
t.string "last_sign_in_ip"
|
27
23
|
t.string "confirmation_token"
|
28
24
|
t.datetime "confirmed_at"
|
29
25
|
t.datetime "confirmation_sent_at"
|
@@ -31,16 +27,14 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
31
27
|
t.string "name"
|
32
28
|
t.string "nickname"
|
33
29
|
t.string "image"
|
34
|
-
t.string "
|
35
|
-
t.string "uid", default: "", null: false
|
30
|
+
t.string "email"
|
36
31
|
t.text "tokens"
|
37
|
-
t.
|
38
|
-
t.datetime "
|
39
|
-
t.
|
40
|
-
t.index ["
|
41
|
-
t.index ["
|
42
|
-
t.index ["
|
43
|
-
t.index ["uid", "provider"], name: "index_evil_users_on_uid_and_provider", unique: true
|
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
|
44
38
|
end
|
45
39
|
|
46
40
|
create_table "lockable_users", force: :cascade do |t|
|
@@ -70,11 +64,6 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
70
64
|
t.string "reset_password_redirect_url"
|
71
65
|
t.boolean "allow_password_change", default: false
|
72
66
|
t.datetime "remember_created_at"
|
73
|
-
t.integer "sign_in_count", default: 0, null: false
|
74
|
-
t.datetime "current_sign_in_at"
|
75
|
-
t.datetime "last_sign_in_at"
|
76
|
-
t.string "current_sign_in_ip"
|
77
|
-
t.string "last_sign_in_ip"
|
78
67
|
t.string "confirmation_token"
|
79
68
|
t.datetime "confirmed_at"
|
80
69
|
t.datetime "confirmation_sent_at"
|
@@ -94,35 +83,6 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
94
83
|
t.index ["uid", "provider"], name: "index_mangs_on_uid_and_provider", unique: true
|
95
84
|
end
|
96
85
|
|
97
|
-
create_table "nice_users", force: :cascade do |t|
|
98
|
-
t.string "provider", null: false
|
99
|
-
t.string "uid", default: "", null: false
|
100
|
-
t.string "encrypted_password", default: "", null: false
|
101
|
-
t.string "reset_password_token"
|
102
|
-
t.datetime "reset_password_sent_at"
|
103
|
-
t.boolean "allow_password_change", default: false
|
104
|
-
t.datetime "remember_created_at"
|
105
|
-
t.integer "sign_in_count", default: 0, null: false
|
106
|
-
t.datetime "current_sign_in_at"
|
107
|
-
t.datetime "last_sign_in_at"
|
108
|
-
t.string "current_sign_in_ip"
|
109
|
-
t.string "last_sign_in_ip"
|
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_nice_users_on_email"
|
122
|
-
t.index ["reset_password_token"], name: "index_nice_users_on_reset_password_token", unique: true
|
123
|
-
t.index ["uid", "provider"], name: "index_nice_users_on_uid_and_provider", unique: true
|
124
|
-
end
|
125
|
-
|
126
86
|
create_table "only_email_users", force: :cascade do |t|
|
127
87
|
t.string "provider", null: false
|
128
88
|
t.string "uid", default: "", null: false
|
@@ -146,11 +106,6 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
146
106
|
t.datetime "reset_password_sent_at"
|
147
107
|
t.boolean "allow_password_change", default: false
|
148
108
|
t.datetime "remember_created_at"
|
149
|
-
t.integer "sign_in_count", default: 0, null: false
|
150
|
-
t.datetime "current_sign_in_at"
|
151
|
-
t.datetime "last_sign_in_at"
|
152
|
-
t.string "current_sign_in_ip"
|
153
|
-
t.string "last_sign_in_ip"
|
154
109
|
t.string "confirmation_token"
|
155
110
|
t.datetime "confirmed_at"
|
156
111
|
t.datetime "confirmation_sent_at"
|
@@ -175,11 +130,6 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
175
130
|
t.datetime "reset_password_sent_at"
|
176
131
|
t.boolean "allow_password_change", default: false
|
177
132
|
t.datetime "remember_created_at"
|
178
|
-
t.integer "sign_in_count", default: 0, null: false
|
179
|
-
t.datetime "current_sign_in_at"
|
180
|
-
t.datetime "last_sign_in_at"
|
181
|
-
t.string "current_sign_in_ip"
|
182
|
-
t.string "last_sign_in_ip"
|
183
133
|
t.string "name"
|
184
134
|
t.string "nickname"
|
185
135
|
t.string "image"
|
@@ -200,11 +150,6 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
200
150
|
t.datetime "reset_password_sent_at"
|
201
151
|
t.boolean "allow_password_change", default: false
|
202
152
|
t.datetime "remember_created_at"
|
203
|
-
t.integer "sign_in_count", default: 0, null: false
|
204
|
-
t.datetime "current_sign_in_at"
|
205
|
-
t.datetime "last_sign_in_at"
|
206
|
-
t.string "current_sign_in_ip"
|
207
|
-
t.string "last_sign_in_ip"
|
208
153
|
t.string "confirmation_token"
|
209
154
|
t.datetime "confirmed_at"
|
210
155
|
t.datetime "confirmation_sent_at"
|
@@ -229,11 +174,6 @@ ActiveRecord::Schema.define(version: 20160629184441) do
|
|
229
174
|
t.string "reset_password_redirect_url"
|
230
175
|
t.boolean "allow_password_change", default: false
|
231
176
|
t.datetime "remember_created_at"
|
232
|
-
t.integer "sign_in_count", default: 0, null: false
|
233
|
-
t.datetime "current_sign_in_at"
|
234
|
-
t.datetime "last_sign_in_at"
|
235
|
-
t.string "current_sign_in_ip"
|
236
|
-
t.string "last_sign_in_ip"
|
237
177
|
t.string "confirmation_token"
|
238
178
|
t.datetime "confirmed_at"
|
239
179
|
t.datetime "confirmation_sent_at"
|
@@ -1,3 +1,17 @@
|
|
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
|
+
|
1
15
|
module MigrationDatabaseHelper
|
2
16
|
def json_supported_database?
|
3
17
|
(postgres? && postgres_correct_version?) || (mysql? && mysql_correct_version?)
|
@@ -26,4 +40,4 @@ module MigrationDatabaseHelper
|
|
26
40
|
def database_version
|
27
41
|
ActiveRecord::Base.connection.select_value('SELECT VERSION()')
|
28
42
|
end
|
29
|
-
end
|
43
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Azpire::V1::HumanResource::User
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
include Mongoid::Locker
|
7
|
+
|
8
|
+
field :locker_locked_at, type: Time
|
9
|
+
field :locker_locked_until, type: Time
|
10
|
+
|
11
|
+
locker locked_at_field: :locker_locked_at,
|
12
|
+
locked_until_field: :locker_locked_until
|
13
|
+
|
14
|
+
## Database authenticatable
|
15
|
+
field :email, type: String, default: ''
|
16
|
+
field :encrypted_password, type: String, default: ''
|
17
|
+
|
18
|
+
## Recoverable
|
19
|
+
field :reset_password_token, type: String
|
20
|
+
field :reset_password_sent_at, type: Time
|
21
|
+
field :reset_password_redirect_url, type: String
|
22
|
+
field :allow_password_change, type: Boolean, default: false
|
23
|
+
|
24
|
+
## Rememberable
|
25
|
+
field :remember_created_at, type: Time
|
26
|
+
|
27
|
+
## Confirmable
|
28
|
+
field :confirmation_token, type: String
|
29
|
+
field :confirmed_at, type: Time
|
30
|
+
field :confirmation_sent_at, type: Time
|
31
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
32
|
+
|
33
|
+
## Lockable
|
34
|
+
# field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
35
|
+
# field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
36
|
+
# field :locked_at, type: Time
|
37
|
+
|
38
|
+
## Required
|
39
|
+
field :provider, type: String
|
40
|
+
field :uid, type: String, default: ''
|
41
|
+
|
42
|
+
## Tokens
|
43
|
+
field :tokens, type: Hash, default: {}
|
44
|
+
|
45
|
+
# Include default devise modules. Others available are:
|
46
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
47
|
+
devise :database_authenticatable, :registerable,
|
48
|
+
:recoverable, :rememberable, :validatable
|
49
|
+
include DeviseTokenAuth::Concerns::User
|
50
|
+
|
51
|
+
index({ email: 1 }, { name: 'email_index', unique: true, background: true })
|
52
|
+
index({ reset_password_token: 1 }, { name: 'reset_password_token_index', unique: true, sparse: true, background: true })
|
53
|
+
index({ confirmation_token: 1 }, { name: 'confirmation_token_index', unique: true, sparse: true, background: true })
|
54
|
+
index({ uid: 1, provider: 1}, { name: 'uid_provider_index', unique: true, background: true })
|
55
|
+
# index({ unlock_token: 1 }, { name: 'unlock_token_index', unique: true, sparse: true, background: true })
|
56
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
DeviseTokenAuth.setup do |config|
|
2
4
|
# By default the authorization headers will change after each request. The
|
3
5
|
# client is responsible for keeping track of the changing tokens. Change
|
@@ -9,6 +11,11 @@ DeviseTokenAuth.setup do |config|
|
|
9
11
|
# determines how long tokens will remain valid after they are issued.
|
10
12
|
# config.token_lifespan = 2.weeks
|
11
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
|
+
|
12
19
|
# Sets the max number of concurrent devices per user, which is 10 by default.
|
13
20
|
# After this limit is reached, the oldest tokens will be removed.
|
14
21
|
# config.max_number_of_devices = 10
|
@@ -45,4 +52,9 @@ DeviseTokenAuth.setup do |config|
|
|
45
52
|
# If, however, you wish to integrate with legacy Devise authentication, you can
|
46
53
|
# do so by enabling this flag. NOTE: This feature is highly experimental!
|
47
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
|
48
60
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :user do
|
3
|
+
email { Faker::Internet.unique.safe_email }
|
4
|
+
password { Faker::Internet.password }
|
5
|
+
provider { 'email' }
|
6
|
+
|
7
|
+
transient do
|
8
|
+
allow_unconfirmed_period { Time.now.utc - Devise.allow_unconfirmed_access_for }
|
9
|
+
end
|
10
|
+
|
11
|
+
trait :with_nickname do
|
12
|
+
nickname { Faker::Internet.username }
|
13
|
+
end
|
14
|
+
|
15
|
+
trait :confirmed do
|
16
|
+
after(:create) { |user| user.confirm }
|
17
|
+
end
|
18
|
+
|
19
|
+
# confirmation period is expired
|
20
|
+
trait :unconfirmed do
|
21
|
+
after(:create) do |user, evaluator|
|
22
|
+
user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
trait :facebook do
|
27
|
+
uid { Faker::Number.number }
|
28
|
+
provider { 'facebook' }
|
29
|
+
end
|
30
|
+
|
31
|
+
trait :locked do
|
32
|
+
after(:create) { |user| user.lock_access! }
|
33
|
+
end
|
34
|
+
|
35
|
+
factory :lockable_user, class: 'LockableUser'
|
36
|
+
factory :mang_user, class: 'Mang'
|
37
|
+
factory :only_email_user, class: 'OnlyEmailUser'
|
38
|
+
factory :scoped_user, class: 'ScopedUser'
|
39
|
+
factory :confirmable_user, class: 'ConfirmableUser'
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class DeviseTokenAuth::BlacklistTest < ActiveSupport::TestCase
|
6
|
+
if defined? Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION
|
7
|
+
describe Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION do
|
8
|
+
test 'should include :tokens' do
|
9
|
+
assert Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION.include?(:tokens)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
else
|
13
|
+
describe Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION do
|
14
|
+
test 'should include :tokens' do
|
15
|
+
assert Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION.include?(:tokens)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class DeviseTokenAuth::CustomRoutesTest < ActiveSupport::TestCase
|
6
|
+
after do
|
7
|
+
Rails.application.reload_routes!
|
8
|
+
end
|
9
|
+
test 'custom controllers' do
|
10
|
+
class ActionDispatch::Routing::Mapper
|
11
|
+
include Mocha::ParameterMatchers
|
12
|
+
end
|
13
|
+
Rails.application.routes.draw do
|
14
|
+
self.expects(:devise_for).with(
|
15
|
+
:users,
|
16
|
+
has_entries(
|
17
|
+
controllers: has_entries(
|
18
|
+
invitations: "custom/invitations", foo: "custom/foo"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
)
|
22
|
+
|
23
|
+
mount_devise_token_auth_for 'User', at: 'my_custom_users', controllers: {
|
24
|
+
invitations: 'custom/invitations',
|
25
|
+
foo: 'custom/foo'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|