devise-security 0.12.0 → 0.16.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 +4 -4
- data/README.md +186 -63
- data/app/controllers/devise/paranoid_verification_code_controller.rb +2 -0
- data/app/controllers/devise/password_expired_controller.rb +13 -6
- data/app/views/devise/paranoid_verification_code/show.html.erb +4 -4
- data/app/views/devise/password_expired/show.html.erb +6 -6
- data/config/locales/by.yml +49 -0
- data/config/locales/cs.yml +41 -0
- data/config/locales/de.yml +30 -7
- data/config/locales/en.yml +25 -1
- data/config/locales/es.yml +19 -6
- data/config/locales/fa.yml +41 -0
- data/config/locales/fr.yml +30 -0
- data/config/locales/hi.yml +42 -0
- data/config/locales/it.yml +35 -4
- data/config/locales/ja.yml +30 -0
- data/config/locales/nl.yml +41 -0
- data/config/locales/pt.yml +41 -0
- data/config/locales/ru.yml +49 -0
- data/config/locales/tr.yml +18 -0
- data/config/locales/uk.yml +49 -0
- data/config/locales/zh_CN.yml +41 -0
- data/config/locales/zh_TW.yml +41 -0
- data/lib/devise-security/controllers/helpers.rb +61 -50
- data/lib/devise-security/hooks/expirable.rb +3 -1
- data/lib/devise-security/hooks/paranoid_verification.rb +2 -0
- data/lib/devise-security/hooks/password_expirable.rb +4 -0
- data/lib/devise-security/hooks/session_limitable.rb +31 -14
- data/lib/devise-security/models/active_record/old_password.rb +5 -0
- data/lib/devise-security/models/compatibility/active_record_patch.rb +40 -0
- data/lib/devise-security/models/compatibility/mongoid_patch.rb +31 -0
- data/lib/devise-security/models/compatibility.rb +8 -15
- data/lib/devise-security/models/database_authenticatable_patch.rb +3 -1
- data/lib/devise-security/models/expirable.rb +8 -2
- data/lib/devise-security/models/mongoid/old_password.rb +21 -0
- data/lib/devise-security/models/paranoid_verification.rb +2 -0
- data/lib/devise-security/models/password_archivable.rb +18 -7
- data/lib/devise-security/models/password_expirable.rb +103 -48
- data/lib/devise-security/models/secure_validatable.rb +26 -6
- data/lib/devise-security/models/security_questionable.rb +2 -0
- data/lib/devise-security/models/session_limitable.rb +19 -2
- data/lib/devise-security/orm/mongoid.rb +7 -0
- data/lib/devise-security/patches/confirmations_controller_captcha.rb +2 -0
- data/lib/devise-security/patches/confirmations_controller_security_question.rb +2 -0
- data/lib/devise-security/patches/controller_captcha.rb +2 -0
- data/lib/devise-security/patches/controller_security_question.rb +3 -1
- data/lib/devise-security/patches/passwords_controller_captcha.rb +2 -0
- data/lib/devise-security/patches/passwords_controller_security_question.rb +2 -0
- data/lib/devise-security/patches/registrations_controller_captcha.rb +2 -0
- data/lib/devise-security/patches/sessions_controller_captcha.rb +2 -0
- data/lib/devise-security/patches/unlocks_controller_captcha.rb +2 -0
- data/lib/devise-security/patches/unlocks_controller_security_question.rb +2 -0
- data/lib/devise-security/patches.rb +2 -0
- data/lib/devise-security/rails.rb +2 -0
- data/lib/devise-security/routes.rb +2 -0
- data/lib/devise-security/validators/password_complexity_validator.rb +35 -0
- data/lib/devise-security/version.rb +3 -1
- data/lib/devise-security.rb +16 -10
- data/lib/generators/devise_security/install_generator.rb +5 -3
- data/lib/generators/templates/devise_security.rb +47 -0
- data/test/{test_captcha_controller.rb → controllers/test_captcha_controller.rb} +2 -0
- data/test/controllers/test_password_expired_controller.rb +110 -0
- data/test/controllers/test_security_question_controller.rb +60 -0
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/captcha/sessions_controller.rb +2 -0
- data/test/dummy/app/controllers/security_question/unlocks_controller.rb +2 -0
- data/test/dummy/app/controllers/widgets_controller.rb +6 -0
- data/test/dummy/app/models/application_record.rb +10 -2
- data/test/dummy/app/models/application_user_record.rb +11 -0
- data/test/dummy/app/models/captcha_user.rb +7 -2
- data/test/dummy/app/models/mongoid/confirmable_fields.rb +13 -0
- data/test/dummy/app/models/mongoid/database_authenticable_fields.rb +17 -0
- data/test/dummy/app/models/mongoid/expirable_fields.rb +11 -0
- data/test/dummy/app/models/mongoid/lockable_fields.rb +13 -0
- data/test/dummy/app/models/mongoid/mappings.rb +13 -0
- data/test/dummy/app/models/mongoid/omniauthable_fields.rb +11 -0
- data/test/dummy/app/models/mongoid/paranoid_verification_fields.rb +10 -0
- data/test/dummy/app/models/mongoid/password_archivable_fields.rb +9 -0
- data/test/dummy/app/models/mongoid/password_expirable_fields.rb +10 -0
- data/test/dummy/app/models/mongoid/recoverable_fields.rb +11 -0
- data/test/dummy/app/models/mongoid/registerable_fields.rb +19 -0
- data/test/dummy/app/models/mongoid/rememberable_fields.rb +10 -0
- data/test/dummy/app/models/mongoid/secure_validatable_fields.rb +11 -0
- data/test/dummy/app/models/mongoid/security_questionable_fields.rb +13 -0
- data/test/dummy/app/models/mongoid/session_limitable_fields.rb +10 -0
- data/test/dummy/app/models/mongoid/timeoutable_fields.rb +9 -0
- data/test/dummy/app/models/mongoid/trackable_fields.rb +14 -0
- data/test/dummy/app/models/mongoid/validatable_fields.rb +7 -0
- data/test/dummy/app/models/secure_user.rb +7 -1
- data/test/dummy/app/models/security_question_user.rb +9 -4
- data/test/dummy/app/models/user.rb +15 -0
- data/test/dummy/app/models/widget.rb +6 -0
- data/test/dummy/app/mongoid/admin.rb +31 -0
- data/test/dummy/app/mongoid/one_user.rb +58 -0
- data/test/dummy/app/mongoid/shim.rb +25 -0
- data/test/dummy/app/mongoid/user_on_engine.rb +41 -0
- data/test/dummy/app/mongoid/user_on_main_app.rb +41 -0
- data/test/dummy/app/mongoid/user_with_validations.rb +37 -0
- data/test/dummy/app/mongoid/user_without_email.rb +35 -0
- data/test/dummy/config/application.rb +13 -7
- data/test/dummy/config/boot.rb +2 -0
- data/test/dummy/config/environment.rb +2 -0
- data/test/dummy/config/environments/test.rb +5 -13
- data/test/dummy/config/initializers/devise.rb +10 -3
- data/test/dummy/config/initializers/migration_class.rb +3 -6
- data/test/dummy/config/mongoid.yml +6 -0
- data/test/dummy/config/routes.rb +6 -3
- data/test/dummy/config.ru +3 -1
- data/test/dummy/db/migrate/20120508165529_create_tables.rb +13 -2
- data/test/dummy/db/migrate/20150402165590_add_verification_columns.rb +2 -0
- data/test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb +2 -0
- data/test/dummy/db/migrate/20160320162345_add_security_questions_fields.rb +2 -0
- data/test/dummy/db/migrate/20180318103603_add_expireable_columns.rb +2 -0
- data/test/dummy/db/migrate/20180318105329_add_confirmable_columns.rb +2 -0
- data/test/dummy/db/migrate/20180318105732_add_rememberable_columns.rb +2 -0
- data/test/dummy/db/migrate/20180318111336_add_recoverable_columns.rb +2 -0
- data/test/dummy/db/migrate/20180319114023_add_widget.rb +2 -0
- data/test/dummy/lib/shared_expirable_columns.rb +14 -0
- data/test/dummy/lib/shared_security_questions_fields.rb +16 -0
- data/test/dummy/lib/shared_user.rb +32 -0
- data/test/dummy/lib/shared_user_with_password_verification.rb +13 -0
- data/test/dummy/lib/shared_user_without_email.rb +28 -0
- data/test/dummy/lib/shared_user_without_omniauth.rb +15 -0
- data/test/dummy/lib/shared_verification_fields.rb +15 -0
- data/test/dummy/log/development.log +883 -0
- data/test/dummy/log/test.log +21689 -0
- data/test/integration/test_password_expirable_workflow.rb +53 -0
- data/test/integration/test_session_limitable_workflow.rb +67 -0
- data/test/orm/active_record.rb +15 -0
- data/test/orm/mongoid.rb +13 -0
- data/test/support/integration_helpers.rb +29 -0
- data/test/support/mongoid.yml +6 -0
- data/test/test_compatibility.rb +13 -0
- data/test/test_complexity_validator.rb +72 -0
- data/test/test_helper.rb +42 -9
- data/test/test_install_generator.rb +19 -2
- data/test/test_paranoid_verification.rb +2 -0
- data/test/test_password_archivable.rb +8 -7
- data/test/test_password_expirable.rb +70 -7
- data/test/test_secure_validatable.rb +97 -21
- data/test/test_session_limitable.rb +57 -0
- data/{lib/generators/templates → test/tmp/config/initializers}/devise-security.rb +12 -3
- data/test/tmp/config/locales/devise.security_extension.by.yml +49 -0
- data/test/tmp/config/locales/devise.security_extension.cs.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.de.yml +39 -0
- data/test/tmp/config/locales/devise.security_extension.en.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.es.yml +30 -0
- data/test/tmp/config/locales/devise.security_extension.fa.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.fr.yml +30 -0
- data/test/tmp/config/locales/devise.security_extension.hi.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.it.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.ja.yml +30 -0
- data/test/tmp/config/locales/devise.security_extension.nl.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.pt.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.ru.yml +49 -0
- data/test/tmp/config/locales/devise.security_extension.tr.yml +18 -0
- data/test/tmp/config/locales/devise.security_extension.uk.yml +49 -0
- data/test/tmp/config/locales/devise.security_extension.zh_CN.yml +41 -0
- data/test/tmp/config/locales/devise.security_extension.zh_TW.yml +41 -0
- metadata +235 -110
- data/.circleci/config.yml +0 -41
- data/.document +0 -5
- data/.gitignore +0 -40
- data/.rubocop.yml +0 -63
- data/.ruby-version +0 -1
- data/.travis.yml +0 -25
- data/Appraisals +0 -19
- data/Gemfile +0 -3
- data/Rakefile +0 -28
- data/devise-security.gemspec +0 -44
- data/gemfiles/rails_4.1_stable.gemfile +0 -8
- data/gemfiles/rails_4.2_stable.gemfile +0 -8
- data/gemfiles/rails_5.0_stable.gemfile +0 -8
- data/gemfiles/rails_5.1_stable.gemfile +0 -8
- data/gemfiles/rails_5.2_rc1.gemfile +0 -8
- data/lib/devise-security/models/old_password.rb +0 -4
- data/lib/devise-security/orm/active_record.rb +0 -18
- data/lib/devise-security/schema.rb +0 -64
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/test_password_expired_controller.rb +0 -44
- data/test/test_security_question_controller.rb +0 -84
@@ -0,0 +1,13 @@
|
|
1
|
+
module ConfirmableFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
## Confirmable
|
8
|
+
field :confirmation_token, type: String
|
9
|
+
field :confirmed_at, type: Time
|
10
|
+
field :confirmation_sent_at, type: Time
|
11
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DatabaseAuthenticatableFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
## Database authenticatable
|
8
|
+
field :username, type: String
|
9
|
+
field :email, type: String, default: ""
|
10
|
+
#validates_presence_of :email
|
11
|
+
|
12
|
+
field :encrypted_password, type: String, default: ""
|
13
|
+
validates_presence_of :encrypted_password
|
14
|
+
|
15
|
+
include Mongoid::Timestamps
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module LockableFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
8
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
9
|
+
field :locked_at, type: Time
|
10
|
+
include Mongoid::Timestamps
|
11
|
+
index({ unlock_token: 1 }, { unique: true })
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Dir[File.expand_path("*_fields.rb", __dir__)].each { |f| require_relative f }
|
2
|
+
|
3
|
+
module Mongoid
|
4
|
+
module Mappings
|
5
|
+
extend ::ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
self.devise_modules.each do |devise_module_name|
|
9
|
+
include "#{devise_module_name.to_s.classify}Fields".constantize
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module ParanoidVerificationFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
field :paranoid_verification_code, type: String
|
7
|
+
field :paranoid_verified_at, type: Time
|
8
|
+
field :paranoid_verification_attempt, type: Integer, default: 0
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RegisterableFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
## Database authenticatable
|
8
|
+
field :email, type: String, default: ""
|
9
|
+
validates_presence_of :email
|
10
|
+
|
11
|
+
field :encrypted_password, type: String, default: ""
|
12
|
+
validates_presence_of :encrypted_password
|
13
|
+
|
14
|
+
field :password_changed_at, type: Time
|
15
|
+
index({ password_changed_at: 1 }, {})
|
16
|
+
index({ email: 1 }, {})
|
17
|
+
include Mongoid::Timestamps
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SecurityQuestionableFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
## Security Questionable
|
8
|
+
field :locked_at, type: Time
|
9
|
+
field :unlock_token, type: String
|
10
|
+
field :security_question_id, type: Integer
|
11
|
+
field :security_question_answer, type: String
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module TrackableFields
|
2
|
+
extend ::ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
## Trackable
|
8
|
+
field :sign_in_count, type: Integer, default: 0
|
9
|
+
field :current_sign_in_at, type: Time
|
10
|
+
field :last_sign_in_at, type: Time
|
11
|
+
field :current_sign_in_ip, type: String
|
12
|
+
field :last_sign_in_ip, type: String
|
13
|
+
end
|
14
|
+
end
|
@@ -1,3 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SecureUser < ApplicationUserRecord
|
2
4
|
devise :database_authenticatable, :secure_validatable, email_validation: false
|
5
|
+
if DEVISE_ORM == :mongoid
|
6
|
+
require './test/dummy/app/models/mongoid/mappings'
|
7
|
+
include ::Mongoid::Mappings
|
8
|
+
end
|
3
9
|
end
|
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SecurityQuestionUser < ApplicationUserRecord
|
4
|
+
devise :database_authenticatable, :lockable, :security_questionable
|
5
|
+
if DEVISE_ORM == :mongoid
|
6
|
+
require './test/dummy/app/models/mongoid/mappings'
|
7
|
+
include ::Mongoid::Mappings
|
8
|
+
field :security_question_answer, type: String
|
9
|
+
end
|
5
10
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class User < ApplicationRecord
|
2
4
|
|
3
5
|
devise :database_authenticatable,
|
@@ -19,4 +21,17 @@ class User < ApplicationRecord
|
|
19
21
|
:validatable
|
20
22
|
|
21
23
|
has_many :widgets
|
24
|
+
|
25
|
+
if DEVISE_ORM == :mongoid
|
26
|
+
require './test/dummy/app/models/mongoid/mappings'
|
27
|
+
include ::Mongoid::Mappings
|
28
|
+
|
29
|
+
def some_method_calling_mongoid
|
30
|
+
Mongoid.logger
|
31
|
+
end
|
32
|
+
elsif DEVISE_ORM == :active_record
|
33
|
+
def some_method_calling_active_record
|
34
|
+
ActiveRecord::Base.transaction {}
|
35
|
+
end
|
36
|
+
end
|
22
37
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shared_admin'
|
4
|
+
|
5
|
+
class Admin
|
6
|
+
include Mongoid::Document
|
7
|
+
include Shim
|
8
|
+
include SharedAdmin
|
9
|
+
|
10
|
+
## Database authenticatable
|
11
|
+
field :email, type: String
|
12
|
+
field :encrypted_password, type: String
|
13
|
+
|
14
|
+
## Recoverable
|
15
|
+
field :reset_password_token, type: String
|
16
|
+
field :reset_password_sent_at, type: Time
|
17
|
+
|
18
|
+
## Rememberable
|
19
|
+
field :remember_created_at, type: Time
|
20
|
+
|
21
|
+
## Confirmable
|
22
|
+
field :confirmation_token, type: String
|
23
|
+
field :confirmed_at, type: Time
|
24
|
+
field :confirmation_sent_at, type: Time
|
25
|
+
field :unconfirmed_email, type: String # Only if using reconfirmable
|
26
|
+
|
27
|
+
## Lockable
|
28
|
+
field :locked_at, type: Time
|
29
|
+
|
30
|
+
field :active, type: Boolean, default: false
|
31
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shared_user_with_password_verification'
|
4
|
+
|
5
|
+
class OneUser
|
6
|
+
include Mongoid::Document
|
7
|
+
include Shim
|
8
|
+
include SharedUserWithPasswordVerification
|
9
|
+
include SharedSecurityQuestionsFields
|
10
|
+
|
11
|
+
field :password_changed_at, type: Time
|
12
|
+
index({ password_changed_at: 1 }, {})
|
13
|
+
|
14
|
+
#field :paranoid_verification_code, type: String
|
15
|
+
#field :paranoid_verified_at, type: Time
|
16
|
+
#field :paranoid_verification_attempt, type: Integer, default: 0
|
17
|
+
|
18
|
+
field :username, type: String
|
19
|
+
field :facebook_token, type: String
|
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
|
+
|
29
|
+
## Rememberable
|
30
|
+
field :remember_created_at, type: Time
|
31
|
+
|
32
|
+
## Trackable
|
33
|
+
field :sign_in_count, type: Integer, default: 0
|
34
|
+
field :current_sign_in_at, type: Time
|
35
|
+
field :last_sign_in_at, type: Time
|
36
|
+
field :current_sign_in_ip, type: String
|
37
|
+
field :last_sign_in_ip, type: String
|
38
|
+
|
39
|
+
## Confirmable
|
40
|
+
field :confirmation_token, type: String
|
41
|
+
field :confirmed_at, type: Time
|
42
|
+
field :confirmation_sent_at, type: Time
|
43
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
44
|
+
|
45
|
+
## Lockable
|
46
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
47
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
48
|
+
field :locked_at, type: Time
|
49
|
+
|
50
|
+
cattr_accessor :validations_performed
|
51
|
+
|
52
|
+
after_validation :after_validation_callback
|
53
|
+
|
54
|
+
def after_validation_callback
|
55
|
+
# used to check in our test if the validations were called
|
56
|
+
@@validations_performed = true
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shim
|
4
|
+
extend ::ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
include ::Mongoid::Timestamps
|
8
|
+
field :created_at, type: DateTime
|
9
|
+
end
|
10
|
+
|
11
|
+
class_methods do
|
12
|
+
def order(attribute)
|
13
|
+
asc(attribute)
|
14
|
+
end
|
15
|
+
|
16
|
+
def find_by_email(email)
|
17
|
+
find_by(email: email)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# overwrite equality (because some devise tests use this for asserting model equality)
|
22
|
+
def ==(other)
|
23
|
+
other.is_a?(self.class) && _id == other._id
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shared_user_without_omniauth'
|
4
|
+
|
5
|
+
class UserOnEngine
|
6
|
+
include Mongoid::Document
|
7
|
+
include Shim
|
8
|
+
include SharedUserWithoutOmniauth
|
9
|
+
|
10
|
+
field :username, type: String
|
11
|
+
field :facebook_token, type: String
|
12
|
+
|
13
|
+
## Database authenticatable
|
14
|
+
field :email, type: String, default: ""
|
15
|
+
field :encrypted_password, type: String, default: ""
|
16
|
+
|
17
|
+
## Recoverable
|
18
|
+
field :reset_password_token, type: String
|
19
|
+
field :reset_password_sent_at, type: Time
|
20
|
+
|
21
|
+
## Rememberable
|
22
|
+
field :remember_created_at, type: Time
|
23
|
+
|
24
|
+
## Trackable
|
25
|
+
field :sign_in_count, type: Integer, default: 0
|
26
|
+
field :current_sign_in_at, type: Time
|
27
|
+
field :last_sign_in_at, type: Time
|
28
|
+
field :current_sign_in_ip, type: String
|
29
|
+
field :last_sign_in_ip, type: String
|
30
|
+
|
31
|
+
## Confirmable
|
32
|
+
field :confirmation_token, type: String
|
33
|
+
field :confirmed_at, type: Time
|
34
|
+
field :confirmation_sent_at, type: Time
|
35
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
36
|
+
|
37
|
+
## Lockable
|
38
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
39
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
40
|
+
field :locked_at, type: Time
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shared_user_without_omniauth'
|
4
|
+
|
5
|
+
class UserOnMainApp
|
6
|
+
include Mongoid::Document
|
7
|
+
include Shim
|
8
|
+
include SharedUserWithoutOmniauth
|
9
|
+
|
10
|
+
field :username, type: String
|
11
|
+
field :facebook_token, type: String
|
12
|
+
|
13
|
+
## Database authenticatable
|
14
|
+
field :email, type: String, default: ""
|
15
|
+
field :encrypted_password, type: String, default: ""
|
16
|
+
|
17
|
+
## Recoverable
|
18
|
+
field :reset_password_token, type: String
|
19
|
+
field :reset_password_sent_at, type: Time
|
20
|
+
|
21
|
+
## Rememberable
|
22
|
+
field :remember_created_at, type: Time
|
23
|
+
|
24
|
+
## Trackable
|
25
|
+
field :sign_in_count, type: Integer, default: 0
|
26
|
+
field :current_sign_in_at, type: Time
|
27
|
+
field :last_sign_in_at, type: Time
|
28
|
+
field :current_sign_in_ip, type: String
|
29
|
+
field :last_sign_in_ip, type: String
|
30
|
+
|
31
|
+
## Confirmable
|
32
|
+
field :confirmation_token, type: String
|
33
|
+
field :confirmed_at, type: Time
|
34
|
+
field :confirmation_sent_at, type: Time
|
35
|
+
# field :unconfirmed_email, type: String # Only if using reconfirmable
|
36
|
+
|
37
|
+
## Lockable
|
38
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
39
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
40
|
+
field :locked_at, type: Time
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "shared_user"
|
4
|
+
|
5
|
+
class UserWithValidations
|
6
|
+
include Mongoid::Document
|
7
|
+
include Shim
|
8
|
+
include SharedUser
|
9
|
+
|
10
|
+
field :username, type: String
|
11
|
+
field :facebook_token, type: String
|
12
|
+
|
13
|
+
## Database authenticatable
|
14
|
+
field :email, type: String, default: ""
|
15
|
+
field :encrypted_password, type: String, default: ""
|
16
|
+
|
17
|
+
## Recoverable
|
18
|
+
field :reset_password_token, type: String
|
19
|
+
field :reset_password_sent_at, type: Time
|
20
|
+
|
21
|
+
## Rememberable
|
22
|
+
field :remember_created_at, type: Time
|
23
|
+
|
24
|
+
## Trackable
|
25
|
+
field :sign_in_count, type: Integer, default: 0
|
26
|
+
field :current_sign_in_at, type: Time
|
27
|
+
field :last_sign_in_at, type: Time
|
28
|
+
field :current_sign_in_ip, type: String
|
29
|
+
field :last_sign_in_ip, type: String
|
30
|
+
|
31
|
+
## Lockable
|
32
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
33
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
34
|
+
field :locked_at, type: Time
|
35
|
+
|
36
|
+
validates :email, presence: true
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "shared_user_without_email"
|
4
|
+
|
5
|
+
class UserWithoutEmail
|
6
|
+
include Mongoid::Document
|
7
|
+
include Shim
|
8
|
+
include SharedUserWithoutEmail
|
9
|
+
|
10
|
+
field :username, type: String
|
11
|
+
field :facebook_token, type: String
|
12
|
+
|
13
|
+
## Database authenticatable
|
14
|
+
field :email, type: String, default: ""
|
15
|
+
field :encrypted_password, type: String, default: ""
|
16
|
+
|
17
|
+
## Recoverable
|
18
|
+
field :reset_password_token, type: String
|
19
|
+
field :reset_password_sent_at, type: Time
|
20
|
+
|
21
|
+
## Rememberable
|
22
|
+
field :remember_created_at, type: Time
|
23
|
+
|
24
|
+
## Trackable
|
25
|
+
field :sign_in_count, type: Integer, default: 0
|
26
|
+
field :current_sign_in_at, type: Time
|
27
|
+
field :last_sign_in_at, type: Time
|
28
|
+
field :current_sign_in_ip, type: String
|
29
|
+
field :last_sign_in_ip, type: String
|
30
|
+
|
31
|
+
## Lockable
|
32
|
+
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
|
33
|
+
field :unlock_token, type: String # Only if unlock strategy is :email or :both
|
34
|
+
field :locked_at, type: Time
|
35
|
+
end
|
@@ -1,21 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('../boot', __FILE__)
|
2
4
|
|
5
|
+
require 'action_mailer/railtie'
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "rails/test_unit/railtie"
|
8
|
+
DEVISE_ORM = ENV.fetch('DEVISE_ORM', 'active_record').to_sym
|
9
|
+
|
10
|
+
Bundler.require :default, DEVISE_ORM
|
11
|
+
require "#{DEVISE_ORM}/railtie"
|
12
|
+
|
3
13
|
require 'rails/all'
|
4
14
|
require 'devise-security'
|
5
15
|
|
6
|
-
if defined?(Bundler)
|
7
|
-
# If you precompile assets before deploying to production, use this line
|
8
|
-
Bundler.require(*Rails.groups(assets: %w[development test]))
|
9
|
-
# If you want your assets lazily compiled in production, use this line
|
10
|
-
# Bundler.require(:default, :assets, Rails.env)
|
11
|
-
end
|
12
|
-
|
13
16
|
module RailsApp
|
14
17
|
class Application < Rails::Application
|
15
18
|
config.encoding = 'utf-8'
|
16
19
|
|
17
20
|
config.filter_parameters += [:password]
|
18
21
|
|
22
|
+
config.autoload_paths += ["#{config.root}/app/#{DEVISE_ORM}"]
|
23
|
+
config.autoload_paths += ["#{config.root}/lib"]
|
24
|
+
|
19
25
|
config.assets.enabled = true
|
20
26
|
|
21
27
|
config.assets.version = '1.0'
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RailsApp::Application.configure do
|
2
4
|
config.cache_classes = true
|
3
5
|
config.eager_load = false
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
8
|
-
else
|
9
|
-
config.serve_static_files = true
|
10
|
-
config.static_cache_control = 'public, max-age=3600'
|
11
|
-
end
|
7
|
+
config.public_file_server.enabled = true
|
8
|
+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
|
12
9
|
|
13
10
|
config.consider_all_requests_local = true
|
14
11
|
config.action_controller.perform_caching = false
|
@@ -25,11 +22,6 @@ RailsApp::Application.configure do
|
|
25
22
|
|
26
23
|
config.active_support.test_order = :sorted
|
27
24
|
config.log_level = :debug
|
28
|
-
if Rails.gem_version >= Gem::Version.new('
|
29
|
-
config.active_record.raise_in_transactional_callbacks = true
|
30
|
-
end
|
31
|
-
if Rails.gem_version.release >= Gem::Version.new('5.2')
|
32
|
-
config.active_record.sqlite3.represent_boolean_as_integer = true
|
33
|
-
end
|
25
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true if Rails.gem_version.release >= Gem::Version.new('5.2') && Rails.gem_version.release < Gem::Version.new('6.0')
|
34
26
|
end
|
35
27
|
ActiveSupport::Deprecation.debug = true
|