devise_token_auth 0.1.1 → 1.3.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.
- checksums.yaml +5 -5
- data/LICENSE +13 -0
- data/README.md +97 -0
- data/Rakefile +12 -4
- data/app/controllers/devise_token_auth/application_controller.rb +89 -22
- data/app/controllers/devise_token_auth/concerns/resource_finder.rb +58 -0
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +199 -0
- data/app/controllers/devise_token_auth/confirmations_controller.rb +79 -14
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +284 -0
- data/app/controllers/devise_token_auth/passwords_controller.rb +196 -35
- data/app/controllers/devise_token_auth/registrations_controller.rb +191 -20
- data/app/controllers/devise_token_auth/sessions_controller.rb +130 -21
- data/app/controllers/devise_token_auth/token_validations_controller.rb +31 -0
- data/app/controllers/devise_token_auth/unlocks_controller.rb +94 -0
- data/app/models/devise_token_auth/concerns/active_record_support.rb +18 -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 +287 -0
- data/app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb +35 -0
- data/app/validators/devise_token_auth_email_validator.rb +31 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise_token_auth/omniauth_external_window.html.erb +38 -0
- data/config/locales/da-DK.yml +52 -0
- data/config/locales/de.yml +51 -0
- data/config/locales/en.yml +60 -0
- data/config/locales/es.yml +51 -0
- data/config/locales/fa.yml +60 -0
- data/config/locales/fr.yml +51 -0
- data/config/locales/he.yml +52 -0
- data/config/locales/it.yml +48 -0
- data/config/locales/ja.yml +60 -0
- data/config/locales/ko.yml +51 -0
- data/config/locales/nl.yml +32 -0
- data/config/locales/pl.yml +51 -0
- data/config/locales/pt-BR.yml +48 -0
- data/config/locales/pt.yml +51 -0
- data/config/locales/ro.yml +48 -0
- data/config/locales/ru.yml +52 -0
- data/config/locales/sq.yml +48 -0
- data/config/locales/sv.yml +52 -0
- data/config/locales/uk.yml +61 -0
- data/config/locales/vi.yml +52 -0
- data/config/locales/zh-CN.yml +48 -0
- data/config/locales/zh-HK.yml +50 -0
- data/config/locales/zh-TW.yml +50 -0
- data/lib/devise_token_auth/blacklist.rb +6 -0
- data/lib/devise_token_auth/controllers/helpers.rb +157 -0
- data/lib/devise_token_auth/controllers/url_helpers.rb +10 -0
- data/lib/devise_token_auth/engine.rb +100 -0
- data/lib/devise_token_auth/errors.rb +8 -0
- data/lib/devise_token_auth/rails/routes.rb +135 -0
- data/lib/devise_token_auth/token_factory.rb +126 -0
- data/lib/devise_token_auth/url.rb +44 -0
- data/lib/devise_token_auth/version.rb +3 -1
- data/lib/devise_token_auth.rb +11 -2
- data/lib/generators/devise_token_auth/USAGE +27 -4
- data/lib/generators/devise_token_auth/install_generator.rb +91 -0
- 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 +18 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth.rb +66 -0
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +49 -0
- 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 +25 -0
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
- data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
- data/test/controllers/custom/custom_registrations_controller_test.rb +63 -0
- data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
- data/test/controllers/custom/custom_token_validations_controller_test.rb +42 -0
- data/test/controllers/demo_group_controller_test.rb +151 -0
- data/test/controllers/demo_mang_controller_test.rb +313 -0
- data/test/controllers/demo_user_controller_test.rb +658 -0
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +275 -0
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +438 -0
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +893 -0
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +920 -0
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +605 -0
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +142 -0
- data/test/controllers/devise_token_auth/unlocks_controller_test.rb +235 -0
- data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
- data/test/controllers/overrides/passwords_controller_test.rb +64 -0
- data/test/controllers/overrides/registrations_controller_test.rb +46 -0
- data/test/controllers/overrides/sessions_controller_test.rb +35 -0
- data/test/controllers/overrides/token_validations_controller_test.rb +43 -0
- data/test/dummy/app/active_record/confirmable_user.rb +11 -0
- data/test/dummy/app/active_record/lockable_user.rb +7 -0
- data/test/dummy/app/active_record/mang.rb +5 -0
- data/test/dummy/app/active_record/only_email_user.rb +7 -0
- data/test/dummy/app/active_record/scoped_user.rb +9 -0
- data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
- 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 +12 -3
- data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
- data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
- data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
- data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
- data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
- data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +29 -0
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +36 -0
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
- data/test/dummy/app/helpers/application_helper.rb +1056 -0
- data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
- 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 +25 -8
- data/test/dummy/config/application.yml.bk +0 -0
- data/test/dummy/config/boot.rb +8 -2
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/development.rb +10 -11
- data/test/dummy/config/environments/production.rb +3 -17
- data/test/dummy/config/environments/test.rb +25 -3
- data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/{config → test/dummy/config}/initializers/devise.rb +63 -31
- data/test/dummy/config/initializers/devise_token_auth.rb +55 -0
- data/test/dummy/config/initializers/figaro.rb +3 -0
- 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 +7 -1
- 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 +55 -1
- data/test/dummy/config/spring.rb +3 -0
- data/test/dummy/config.ru +14 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +58 -0
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +57 -0
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +55 -0
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +56 -0
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +56 -0
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +56 -0
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +56 -0
- data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
- data/test/dummy/db/schema.rb +180 -28
- data/test/dummy/lib/migration_database_helper.rb +43 -0
- data/test/dummy/tmp/generators/app/models/user.rb +11 -0
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +66 -0
- data/{db/migrate/20140628234942_devise_token_auth_create_users.rb → test/dummy/tmp/generators/db/migrate/20240519164408_devise_token_auth_create_users.rb} +16 -23
- 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 +30 -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 +26 -0
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +217 -0
- 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 +25 -0
- 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 +29 -0
- data/test/models/user_test.rb +251 -0
- data/test/support/controllers/routes.rb +43 -0
- data/test/test_helper.rb +136 -10
- metadata +368 -80
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -3
- data/app/assets/javascripts/devise_token_auth/application.js +0 -13
- data/app/assets/stylesheets/devise_token_auth/application.css +0 -15
- data/app/controllers/devise_token_auth/auth_controller.rb +0 -62
- data/app/helpers/devise_token_auth/application_helper.rb +0 -4
- data/app/models/user.rb +0 -6
- data/app/views/devise_token_auth/omniauth_success.html.erb +0 -7
- data/app/views/layouts/omniauth_response.html.erb +0 -20
- data/config/locales/devise.en.yml +0 -59
- data/config/routes.rb +0 -14
- data/lib/generators/devise_token_auth/devise_token_auth_generator.rb +0 -3
- data/test/devise_token_auth_test.rb +0 -7
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config/application.yml +0 -13
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/initializers/assets.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140629011345_devise_token_auth_create_users.devise_token_auth.rb +0 -57
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -3406
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +0 -10
- data/test/lib/generators/devise_token_auth/devise_token_auth_generator_test.rb +0 -16
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module FavoriteColor
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
validates :operating_thetan, numericality: true, allow_nil: true
|
|
6
|
+
validate :ensure_correct_favorite_color
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def ensure_correct_favorite_color
|
|
10
|
+
if favorite_color && (favorite_color != '')
|
|
11
|
+
unless ApplicationHelper::COLOR_NAMES.any?{ |s| s.casecmp(favorite_color)==0 }
|
|
12
|
+
matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color)
|
|
13
|
+
closest_match = matches.last[:string]
|
|
14
|
+
second_closest_match = matches[-2][:string]
|
|
15
|
+
errors.add(:favorite_color, "We've never heard of the color \"#{favorite_color}\". Did you mean \"#{closest_match}\"? Or perhaps \"#{second_closest_match}\"?")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ConfirmableUser
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Recoverable
|
|
24
|
+
field :reset_password_token, type: String
|
|
25
|
+
field :reset_password_sent_at, type: Time
|
|
26
|
+
field :reset_password_redirect_url, type: String
|
|
27
|
+
field :allow_password_change, type: Boolean, default: false
|
|
28
|
+
|
|
29
|
+
## Rememberable
|
|
30
|
+
field :remember_created_at, type: Time
|
|
31
|
+
|
|
32
|
+
## Confirmable
|
|
33
|
+
field :confirmation_token, type: String
|
|
34
|
+
field :confirmed_at, type: Time
|
|
35
|
+
field :confirmation_sent_at, type: Time
|
|
36
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
|
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.
|
|
46
|
+
devise :database_authenticatable, :registerable,
|
|
47
|
+
:recoverable, :rememberable, :trackable,
|
|
48
|
+
:validatable, :confirmable
|
|
49
|
+
DeviseTokenAuth.send_confirmation_email = true
|
|
50
|
+
include DeviseTokenAuth::Concerns::User
|
|
51
|
+
DeviseTokenAuth.send_confirmation_email = false
|
|
52
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class LockableUser
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Lockable
|
|
24
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
|
25
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
|
26
|
+
field :locked_at, type: Time
|
|
27
|
+
|
|
28
|
+
## Required
|
|
29
|
+
field :provider, type: String
|
|
30
|
+
field :uid, type: String, default: ''
|
|
31
|
+
|
|
32
|
+
## Tokens
|
|
33
|
+
field :tokens, type: Hash, default: {}
|
|
34
|
+
|
|
35
|
+
# Include default devise modules.
|
|
36
|
+
devise :database_authenticatable, :registerable, :lockable
|
|
37
|
+
include DeviseTokenAuth::Concerns::User
|
|
38
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Mang
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Recoverable
|
|
24
|
+
field :reset_password_token, type: String
|
|
25
|
+
field :reset_password_sent_at, type: Time
|
|
26
|
+
field :reset_password_redirect_url, type: String
|
|
27
|
+
field :allow_password_change, type: Boolean, default: false
|
|
28
|
+
|
|
29
|
+
## Rememberable
|
|
30
|
+
field :remember_created_at, type: Time
|
|
31
|
+
|
|
32
|
+
## Confirmable
|
|
33
|
+
field :confirmation_token, type: String
|
|
34
|
+
field :confirmed_at, type: Time
|
|
35
|
+
field :confirmation_sent_at, type: Time
|
|
36
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
|
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 DeviseTokenAuth::Concerns::User
|
|
46
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class OnlyEmailUser
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Required
|
|
24
|
+
field :provider, type: String
|
|
25
|
+
field :uid, type: String, default: ''
|
|
26
|
+
|
|
27
|
+
## Tokens
|
|
28
|
+
field :tokens, type: Hash, default: {}
|
|
29
|
+
|
|
30
|
+
# Include default devise modules.
|
|
31
|
+
devise :database_authenticatable, :registerable
|
|
32
|
+
include DeviseTokenAuth::Concerns::User
|
|
33
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ScopedUser
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Recoverable
|
|
24
|
+
field :reset_password_token, type: String
|
|
25
|
+
field :reset_password_sent_at, type: Time
|
|
26
|
+
field :reset_password_redirect_url, type: String
|
|
27
|
+
field :allow_password_change, type: Boolean, default: false
|
|
28
|
+
|
|
29
|
+
## Rememberable
|
|
30
|
+
field :remember_created_at, type: Time
|
|
31
|
+
|
|
32
|
+
## Confirmable
|
|
33
|
+
field :confirmation_token, type: String
|
|
34
|
+
field :confirmed_at, type: Time
|
|
35
|
+
field :confirmation_sent_at, type: Time
|
|
36
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
|
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.
|
|
46
|
+
devise :database_authenticatable, :registerable,
|
|
47
|
+
:recoverable, :rememberable, :trackable,
|
|
48
|
+
:validatable, :confirmable, :omniauthable
|
|
49
|
+
include DeviseTokenAuth::Concerns::User
|
|
50
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UnconfirmableUser
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Recoverable
|
|
24
|
+
field :reset_password_token, type: String
|
|
25
|
+
field :reset_password_sent_at, type: Time
|
|
26
|
+
field :reset_password_redirect_url, type: String
|
|
27
|
+
field :allow_password_change, type: Boolean, default: false
|
|
28
|
+
|
|
29
|
+
## Rememberable
|
|
30
|
+
field :remember_created_at, type: Time
|
|
31
|
+
|
|
32
|
+
## Required
|
|
33
|
+
field :provider, type: String
|
|
34
|
+
field :uid, type: String, default: ''
|
|
35
|
+
|
|
36
|
+
## Tokens
|
|
37
|
+
field :tokens, type: Hash, default: {}
|
|
38
|
+
|
|
39
|
+
# Include default devise modules.
|
|
40
|
+
devise :database_authenticatable, :registerable,
|
|
41
|
+
:recoverable, :rememberable, :trackable,
|
|
42
|
+
:validatable, :omniauthable
|
|
43
|
+
include DeviseTokenAuth::Concerns::User
|
|
44
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UnregisterableUser
|
|
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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
|
|
19
|
+
## Database authenticatable
|
|
20
|
+
field :email, type: String, default: ''
|
|
21
|
+
field :encrypted_password, type: String, default: ''
|
|
22
|
+
|
|
23
|
+
## Recoverable
|
|
24
|
+
field :reset_password_token, type: String
|
|
25
|
+
field :reset_password_sent_at, type: Time
|
|
26
|
+
field :reset_password_redirect_url, type: String
|
|
27
|
+
field :allow_password_change, type: Boolean, default: false
|
|
28
|
+
|
|
29
|
+
## Confirmable
|
|
30
|
+
field :confirmation_token, type: String
|
|
31
|
+
field :confirmed_at, type: Time
|
|
32
|
+
field :confirmation_sent_at, type: Time
|
|
33
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
|
34
|
+
|
|
35
|
+
## Required
|
|
36
|
+
field :provider, type: String
|
|
37
|
+
field :uid, type: String, default: ''
|
|
38
|
+
|
|
39
|
+
## Tokens
|
|
40
|
+
field :tokens, type: Hash, default: {}
|
|
41
|
+
|
|
42
|
+
# Include default devise modules.
|
|
43
|
+
devise :database_authenticatable, :recoverable,
|
|
44
|
+
:trackable, :validatable, :confirmable,
|
|
45
|
+
:omniauthable
|
|
46
|
+
include DeviseTokenAuth::Concerns::User
|
|
47
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class 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
|
+
## User Info
|
|
15
|
+
field :name, type: String
|
|
16
|
+
field :nickname, type: String
|
|
17
|
+
field :image, type: String
|
|
18
|
+
field :favorite_color, type: String
|
|
19
|
+
field :operating_thetan, type: Integer
|
|
20
|
+
|
|
21
|
+
## Database authenticatable
|
|
22
|
+
field :email, type: String, default: ''
|
|
23
|
+
field :encrypted_password, type: String, default: ''
|
|
24
|
+
|
|
25
|
+
## Recoverable
|
|
26
|
+
field :reset_password_token, type: String
|
|
27
|
+
field :reset_password_sent_at, type: Time
|
|
28
|
+
field :reset_password_redirect_url, type: String
|
|
29
|
+
field :allow_password_change, type: Boolean, default: false
|
|
30
|
+
|
|
31
|
+
## Rememberable
|
|
32
|
+
field :remember_created_at, type: Time
|
|
33
|
+
|
|
34
|
+
## Confirmable
|
|
35
|
+
field :confirmation_token, type: String
|
|
36
|
+
field :confirmed_at, type: Time
|
|
37
|
+
field :confirmation_sent_at, type: Time
|
|
38
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
|
39
|
+
|
|
40
|
+
## Required
|
|
41
|
+
field :provider, type: String
|
|
42
|
+
field :uid, type: String, default: ''
|
|
43
|
+
|
|
44
|
+
## Tokens
|
|
45
|
+
field :tokens, type: Hash, default: {}
|
|
46
|
+
|
|
47
|
+
include DeviseTokenAuth::Concerns::User
|
|
48
|
+
include FavoriteColor
|
|
49
|
+
end
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require File.expand_path('boot', __dir__)
|
|
4
|
+
|
|
5
|
+
require 'logger'
|
|
6
|
+
require 'action_controller/railtie'
|
|
7
|
+
require 'action_mailer/railtie'
|
|
8
|
+
require 'rails/generators'
|
|
3
9
|
require 'rack/cors'
|
|
4
|
-
require 'rails/all'
|
|
5
10
|
|
|
6
11
|
Bundler.require(*Rails.groups)
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
case DEVISE_TOKEN_AUTH_ORM
|
|
15
|
+
when :active_record
|
|
16
|
+
require 'active_record/railtie'
|
|
17
|
+
when :mongoid
|
|
18
|
+
require 'mongoid'
|
|
19
|
+
require 'mongoid-locker'
|
|
20
|
+
end
|
|
21
|
+
rescue LoadError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require 'devise_token_auth'
|
|
8
25
|
|
|
9
26
|
module Dummy
|
|
10
27
|
class Application < Rails::Application
|
|
@@ -19,12 +36,12 @@ module Dummy
|
|
|
19
36
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
20
37
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
21
38
|
# config.i18n.default_locale = :de
|
|
39
|
+
config.autoload_paths << Rails.root.join('lib')
|
|
40
|
+
config.autoload_paths += ["#{config.root}/app/#{DEVISE_TOKEN_AUTH_ORM}"]
|
|
22
41
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
origins '*'
|
|
27
|
-
resource '*', :headers => :any, :methods => [:get, :post, :options, :delete, :put]
|
|
42
|
+
if DEVISE_TOKEN_AUTH_ORM == :mongoid
|
|
43
|
+
Mongoid.configure do |config|
|
|
44
|
+
config.load! Rails.root.join('./config/mongoid.yml')
|
|
28
45
|
end
|
|
29
46
|
end
|
|
30
47
|
end
|
|
Binary file
|
data/test/dummy/config/boot.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
unless defined?(DEVISE_TOKEN_AUTH_ORM)
|
|
4
|
+
DEVISE_TOKEN_AUTH_ORM = (ENV["DEVISE_TOKEN_AUTH_ORM"] || :active_record).to_sym
|
|
5
|
+
end
|
|
6
|
+
|
|
1
7
|
# Set up gems listed in the Gemfile.
|
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
|
3
9
|
|
|
4
10
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
|
11
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.configure do
|
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
5
|
|
|
@@ -14,7 +16,12 @@ Rails.application.configure do
|
|
|
14
16
|
config.action_controller.perform_caching = false
|
|
15
17
|
|
|
16
18
|
# Don't care if the mailer can't send.
|
|
17
|
-
config.action_mailer.raise_delivery_errors =
|
|
19
|
+
config.action_mailer.raise_delivery_errors = true
|
|
20
|
+
|
|
21
|
+
# use mailcatcher for development
|
|
22
|
+
config.action_mailer.default_url_options = { host: 'devise-token-auth.dev' }
|
|
23
|
+
config.action_mailer.delivery_method = :smtp
|
|
24
|
+
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
|
|
18
25
|
|
|
19
26
|
# Print deprecation notices to the Rails logger.
|
|
20
27
|
config.active_support.deprecation = :log
|
|
@@ -22,16 +29,8 @@ Rails.application.configure do
|
|
|
22
29
|
# Raise an error on page load if there are pending migrations.
|
|
23
30
|
config.active_record.migration_error = :page_load
|
|
24
31
|
|
|
25
|
-
# Debug mode disables concatenation and preprocessing of assets.
|
|
26
|
-
# This option may cause significant delays in view rendering with a large
|
|
27
|
-
# number of complex assets.
|
|
28
|
-
config.assets.debug = true
|
|
29
|
-
|
|
30
|
-
# Adds additional error checking when serving assets at runtime.
|
|
31
|
-
# Checks for improperly declared sprockets dependencies.
|
|
32
|
-
# Raises helpful error messages.
|
|
33
|
-
config.assets.raise_runtime_errors = true
|
|
34
|
-
|
|
35
32
|
# Raises error for missing translations
|
|
36
33
|
# config.action_view.raise_on_missing_translations = true
|
|
34
|
+
|
|
35
|
+
OmniAuth.config.full_host = 'http://devise-token-auth.dev'
|
|
37
36
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.configure do
|
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
5
|
|
|
@@ -20,19 +22,7 @@ Rails.application.configure do
|
|
|
20
22
|
# config.action_dispatch.rack_cache = true
|
|
21
23
|
|
|
22
24
|
# Disable Rails's static asset server (Apache or nginx will already do this).
|
|
23
|
-
config.
|
|
24
|
-
|
|
25
|
-
# Compress JavaScripts and CSS.
|
|
26
|
-
config.assets.js_compressor = :uglifier
|
|
27
|
-
# config.assets.css_compressor = :sass
|
|
28
|
-
|
|
29
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
|
30
|
-
config.assets.compile = false
|
|
31
|
-
|
|
32
|
-
# Generate digests for assets URLs.
|
|
33
|
-
config.assets.digest = true
|
|
34
|
-
|
|
35
|
-
# `config.assets.precompile` has moved to config/initializers/assets.rb
|
|
25
|
+
config.serve_static_files = false
|
|
36
26
|
|
|
37
27
|
# Specifies the header that your server uses for sending files.
|
|
38
28
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
|
@@ -56,10 +46,6 @@ Rails.application.configure do
|
|
|
56
46
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
|
57
47
|
# config.action_controller.asset_host = "http://assets.example.com"
|
|
58
48
|
|
|
59
|
-
# Precompile additional assets.
|
|
60
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
|
61
|
-
# config.assets.precompile += %w( search.js )
|
|
62
|
-
|
|
63
49
|
# Ignore bad email addresses and do not raise email delivery errors.
|
|
64
50
|
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
|
65
51
|
# config.action_mailer.raise_delivery_errors = false
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Rails.application.configure do
|
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
5
|
|
|
@@ -13,15 +15,31 @@ Rails.application.configure do
|
|
|
13
15
|
config.eager_load = false
|
|
14
16
|
|
|
15
17
|
# Configure static asset server for tests with Cache-Control for performance.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
Rails::VERSION::MAJOR >= 5 ?
|
|
19
|
+
(config.public_file_server.enabled = true) :
|
|
20
|
+
(config.serve_static_files = true)
|
|
21
|
+
|
|
22
|
+
Rails::VERSION::MAJOR >= 5 ?
|
|
23
|
+
(config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }) :
|
|
24
|
+
(config.static_cache_control = 'public, max-age=3600')
|
|
25
|
+
|
|
26
|
+
if Rails::VERSION::MAJOR < 7 && ENV['DEVISE_TOKEN_AUTH_ORM'] != 'mongoid'
|
|
27
|
+
config.active_record.legacy_connection_handling = false
|
|
28
|
+
end
|
|
18
29
|
|
|
19
30
|
# Show full error reports and disable caching.
|
|
20
31
|
config.consider_all_requests_local = true
|
|
21
32
|
config.action_controller.perform_caching = false
|
|
22
33
|
|
|
23
34
|
# Raise exceptions instead of rendering exception templates.
|
|
24
|
-
|
|
35
|
+
# Rails 7.1 turned this into an enum; `false` is no longer recognised and
|
|
36
|
+
# falls through to the "show everything" default. Note the version check must
|
|
37
|
+
# not be `MAJOR >= 7 && MINOR > 0`, which is false on Rails 8.0.
|
|
38
|
+
if Rails.gem_version >= Gem::Version.new('7.1')
|
|
39
|
+
config.action_dispatch.show_exceptions = :none
|
|
40
|
+
else
|
|
41
|
+
config.action_dispatch.show_exceptions = false
|
|
42
|
+
end
|
|
25
43
|
|
|
26
44
|
# Disable request forgery protection in test environment.
|
|
27
45
|
config.action_controller.allow_forgery_protection = false
|
|
@@ -30,10 +48,14 @@ Rails.application.configure do
|
|
|
30
48
|
# The :test delivery method accumulates sent emails in the
|
|
31
49
|
# ActionMailer::Base.deliveries array.
|
|
32
50
|
config.action_mailer.delivery_method = :test
|
|
51
|
+
config.action_mailer.default_url_options = { host: 'localhost' }
|
|
33
52
|
|
|
34
53
|
# Print deprecation notices to the stderr.
|
|
35
54
|
config.active_support.deprecation = :stderr
|
|
36
55
|
|
|
37
56
|
# Raises error for missing translations
|
|
38
57
|
# config.action_view.raise_on_missing_translations = true
|
|
58
|
+
|
|
59
|
+
# randomize test order
|
|
60
|
+
config.active_support.test_order = :random
|
|
39
61
|
end
|