devise 4.4.3 → 4.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +174 -4
- data/MIT-LICENSE +2 -1
- data/README.md +129 -65
- data/app/controllers/devise/confirmations_controller.rb +1 -0
- data/app/controllers/devise/passwords_controller.rb +3 -2
- data/app/controllers/devise/registrations_controller.rb +27 -9
- data/app/controllers/devise/sessions_controller.rb +2 -2
- data/app/controllers/devise/unlocks_controller.rb +1 -0
- data/app/controllers/devise_controller.rb +17 -3
- data/app/helpers/devise_helper.rb +21 -18
- data/app/mailers/devise/mailer.rb +5 -5
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +5 -5
- data/app/views/devise/registrations/new.html.erb +3 -3
- data/app/views/devise/sessions/new.html.erb +3 -3
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/_links.html.erb +8 -8
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +3 -2
- data/lib/devise/controllers/helpers.rb +10 -8
- data/lib/devise/controllers/responder.rb +35 -0
- data/lib/devise/controllers/sign_in_out.rb +9 -4
- data/lib/devise/controllers/url_helpers.rb +1 -1
- data/lib/devise/failure_app.rb +41 -8
- data/lib/devise/hooks/csrf_cleaner.rb +6 -1
- data/lib/devise/hooks/lockable.rb +2 -5
- data/lib/devise/hooks/timeoutable.rb +2 -2
- data/lib/devise/mapping.rb +1 -1
- data/lib/devise/models/authenticatable.rb +51 -48
- data/lib/devise/models/confirmable.rb +34 -40
- data/lib/devise/models/database_authenticatable.rb +54 -35
- data/lib/devise/models/lockable.rb +13 -5
- data/lib/devise/models/omniauthable.rb +2 -2
- data/lib/devise/models/recoverable.rb +8 -19
- data/lib/devise/models/registerable.rb +2 -0
- data/lib/devise/models/rememberable.rb +2 -2
- data/lib/devise/models/timeoutable.rb +1 -1
- data/lib/devise/models/trackable.rb +9 -2
- data/lib/devise/models/validatable.rb +4 -9
- data/lib/devise/models.rb +1 -0
- data/lib/devise/omniauth.rb +2 -5
- data/lib/devise/orm.rb +71 -0
- data/lib/devise/parameter_filter.rb +2 -0
- data/lib/devise/parameter_sanitizer.rb +13 -1
- data/lib/devise/rails/deprecated_constant_accessor.rb +39 -0
- data/lib/devise/rails/routes.rb +6 -6
- data/lib/devise/rails.rb +4 -0
- data/lib/devise/secret_key_finder.rb +2 -0
- data/lib/devise/strategies/authenticatable.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +6 -1
- data/lib/devise/test/controller_helpers.rb +5 -3
- data/lib/devise/test/integration_helpers.rb +1 -1
- data/lib/devise/test_helpers.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +38 -11
- data/lib/generators/active_record/devise_generator.rb +26 -11
- data/lib/generators/devise/controllers_generator.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +1 -1
- data/lib/generators/devise/install_generator.rb +1 -5
- data/lib/generators/devise/orm_helpers.rb +2 -2
- data/lib/generators/devise/views_generator.rb +1 -1
- data/lib/generators/mongoid/devise_generator.rb +5 -5
- data/lib/generators/templates/README +9 -1
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
- data/lib/generators/templates/devise.rb +38 -8
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +5 -1
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +10 -2
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +4 -1
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +12 -4
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +11 -3
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +7 -2
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +4 -1
- metadata +23 -316
- data/.gitignore +0 -10
- data/.travis.yml +0 -68
- data/.yardopts +0 -9
- data/CODE_OF_CONDUCT.md +0 -22
- data/CONTRIBUTING.md +0 -79
- data/Gemfile +0 -39
- data/Gemfile.lock +0 -193
- data/ISSUE_TEMPLATE.md +0 -19
- data/Rakefile +0 -37
- data/bin/test +0 -13
- data/devise.gemspec +0 -28
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-4.1-stable +0 -32
- data/gemfiles/Gemfile.rails-4.1-stable.lock +0 -171
- data/gemfiles/Gemfile.rails-4.2-stable +0 -32
- data/gemfiles/Gemfile.rails-4.2-stable.lock +0 -192
- data/gemfiles/Gemfile.rails-5.0-stable +0 -33
- data/gemfiles/Gemfile.rails-5.0-stable.lock +0 -192
- data/gemfiles/Gemfile.rails-5.2-rc1 +0 -26
- data/gemfiles/Gemfile.rails-5.2-rc1.lock +0 -201
- data/guides/bug_report_templates/integration_test.rb +0 -106
- data/test/controllers/custom_registrations_controller_test.rb +0 -42
- data/test/controllers/custom_strategy_test.rb +0 -66
- data/test/controllers/helper_methods_test.rb +0 -24
- data/test/controllers/helpers_test.rb +0 -318
- data/test/controllers/inherited_controller_i18n_messages_test.rb +0 -53
- data/test/controllers/internal_helpers_test.rb +0 -129
- data/test/controllers/load_hooks_controller_test.rb +0 -21
- data/test/controllers/passwords_controller_test.rb +0 -34
- data/test/controllers/sessions_controller_test.rb +0 -108
- data/test/controllers/url_helpers_test.rb +0 -67
- data/test/delegator_test.rb +0 -21
- data/test/devise_test.rb +0 -109
- data/test/failure_app_test.rb +0 -340
- data/test/generators/active_record_generator_test.rb +0 -130
- data/test/generators/controllers_generator_test.rb +0 -50
- data/test/generators/devise_generator_test.rb +0 -41
- data/test/generators/install_generator_test.rb +0 -26
- data/test/generators/mongoid_generator_test.rb +0 -25
- data/test/generators/views_generator_test.rb +0 -105
- data/test/helpers/devise_helper_test.rb +0 -51
- data/test/integration/authenticatable_test.rb +0 -706
- data/test/integration/confirmable_test.rb +0 -326
- data/test/integration/database_authenticatable_test.rb +0 -97
- data/test/integration/http_authenticatable_test.rb +0 -114
- data/test/integration/lockable_test.rb +0 -242
- data/test/integration/mounted_engine_test.rb +0 -38
- data/test/integration/omniauthable_test.rb +0 -148
- data/test/integration/recoverable_test.rb +0 -349
- data/test/integration/registerable_test.rb +0 -365
- data/test/integration/rememberable_test.rb +0 -219
- data/test/integration/timeoutable_test.rb +0 -186
- data/test/integration/trackable_test.rb +0 -99
- data/test/mailers/confirmation_instructions_test.rb +0 -117
- data/test/mailers/email_changed_test.rb +0 -132
- data/test/mailers/mailer_test.rb +0 -20
- data/test/mailers/reset_password_instructions_test.rb +0 -98
- data/test/mailers/unlock_instructions_test.rb +0 -93
- data/test/mapping_test.rb +0 -136
- data/test/models/authenticatable_test.rb +0 -25
- data/test/models/confirmable_test.rb +0 -549
- data/test/models/database_authenticatable_test.rb +0 -283
- data/test/models/lockable_test.rb +0 -352
- data/test/models/omniauthable_test.rb +0 -9
- data/test/models/recoverable_test.rb +0 -263
- data/test/models/registerable_test.rb +0 -9
- data/test/models/rememberable_test.rb +0 -184
- data/test/models/serializable_test.rb +0 -60
- data/test/models/timeoutable_test.rb +0 -53
- data/test/models/trackable_test.rb +0 -62
- data/test/models/validatable_test.rb +0 -121
- data/test/models_test.rb +0 -155
- data/test/omniauth/config_test.rb +0 -61
- data/test/omniauth/url_helpers_test.rb +0 -53
- data/test/orm/active_record.rb +0 -24
- data/test/orm/mongoid.rb +0 -15
- data/test/parameter_sanitizer_test.rb +0 -77
- data/test/rails_app/Rakefile +0 -6
- data/test/rails_app/app/active_record/admin.rb +0 -8
- data/test/rails_app/app/active_record/shim.rb +0 -4
- data/test/rails_app/app/active_record/user.rb +0 -20
- data/test/rails_app/app/active_record/user_on_engine.rb +0 -9
- data/test/rails_app/app/active_record/user_on_main_app.rb +0 -9
- data/test/rails_app/app/active_record/user_with_validations.rb +0 -12
- data/test/rails_app/app/active_record/user_without_email.rb +0 -10
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -8
- data/test/rails_app/app/controllers/admins_controller.rb +0 -8
- data/test/rails_app/app/controllers/application_controller.rb +0 -13
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +0 -32
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +0 -33
- data/test/rails_app/app/controllers/home_controller.rb +0 -31
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -4
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -4
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -16
- data/test/rails_app/app/controllers/users_controller.rb +0 -33
- data/test/rails_app/app/helpers/application_helper.rb +0 -5
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +0 -5
- data/test/rails_app/app/mailers/users/mailer.rb +0 -5
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +0 -6
- data/test/rails_app/app/mongoid/admin.rb +0 -31
- data/test/rails_app/app/mongoid/shim.rb +0 -25
- data/test/rails_app/app/mongoid/user.rb +0 -50
- data/test/rails_app/app/mongoid/user_on_engine.rb +0 -41
- data/test/rails_app/app/mongoid/user_on_main_app.rb +0 -41
- data/test/rails_app/app/mongoid/user_with_validations.rb +0 -37
- data/test/rails_app/app/mongoid/user_without_email.rb +0 -35
- data/test/rails_app/app/views/admins/index.html.erb +0 -1
- data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/home/index.html.erb +0 -1
- data/test/rails_app/app/views/home/join.html.erb +0 -1
- data/test/rails_app/app/views/home/private.html.erb +0 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/layouts/application.html.erb +0 -24
- data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
- data/test/rails_app/app/views/users/index.html.erb +0 -1
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
- data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
- data/test/rails_app/bin/bundle +0 -3
- data/test/rails_app/bin/rails +0 -4
- data/test/rails_app/bin/rake +0 -4
- data/test/rails_app/config/application.rb +0 -48
- data/test/rails_app/config/boot.rb +0 -27
- data/test/rails_app/config/database.yml +0 -18
- data/test/rails_app/config/environment.rb +0 -7
- data/test/rails_app/config/environments/development.rb +0 -32
- data/test/rails_app/config/environments/production.rb +0 -88
- data/test/rails_app/config/environments/test.rb +0 -47
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -9
- data/test/rails_app/config/initializers/devise.rb +0 -182
- data/test/rails_app/config/initializers/inflections.rb +0 -4
- data/test/rails_app/config/initializers/secret_token.rb +0 -5
- data/test/rails_app/config/initializers/session_store.rb +0 -3
- data/test/rails_app/config/routes.rb +0 -128
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -77
- data/test/rails_app/db/schema.rb +0 -57
- data/test/rails_app/lib/shared_admin.rb +0 -23
- data/test/rails_app/lib/shared_user.rb +0 -32
- data/test/rails_app/lib/shared_user_without_email.rb +0 -28
- data/test/rails_app/lib/shared_user_without_omniauth.rb +0 -15
- data/test/rails_app/public/404.html +0 -26
- data/test/rails_app/public/422.html +0 -26
- data/test/rails_app/public/500.html +0 -26
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_test.rb +0 -11
- data/test/routes_test.rb +0 -281
- data/test/secret_key_finder_test.rb +0 -97
- data/test/support/action_controller/record_identifier.rb +0 -12
- data/test/support/assertions.rb +0 -30
- data/test/support/helpers.rb +0 -83
- data/test/support/http_method_compatibility.rb +0 -53
- data/test/support/integration.rb +0 -95
- data/test/support/locale/en.yml +0 -8
- data/test/support/mongoid.yml +0 -6
- data/test/support/webrat/integrations/rails.rb +0 -35
- data/test/test/controller_helpers_test.rb +0 -193
- data/test/test/integration_helpers_test.rb +0 -34
- data/test/test_helper.rb +0 -36
- data/test/test_models.rb +0 -35
@@ -1,88 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RailsApp::Application.configure do
|
4
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
-
|
6
|
-
# Code is not reloaded between requests.
|
7
|
-
config.cache_classes = true
|
8
|
-
|
9
|
-
# Eager load code on boot. This eager loads most of Rails and
|
10
|
-
# your application in memory, allowing both thread web servers
|
11
|
-
# and those relying on copy on write to perform better.
|
12
|
-
# Rake tasks automatically ignore this option for performance.
|
13
|
-
config.eager_load = true
|
14
|
-
|
15
|
-
# Full error reports are disabled and caching is turned on.
|
16
|
-
config.consider_all_requests_local = false
|
17
|
-
config.action_controller.perform_caching = true
|
18
|
-
|
19
|
-
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
20
|
-
# Add `rack-cache` to your Gemfile before enabling this.
|
21
|
-
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
22
|
-
# config.action_dispatch.rack_cache = true
|
23
|
-
|
24
|
-
# Disable Rails's static asset server (Apache or nginx will already do this).
|
25
|
-
if Rails.version >= "5.0.0"
|
26
|
-
config.public_file_server.enabled = false
|
27
|
-
elsif Rails.version >= "4.2.0"
|
28
|
-
config.serve_static_files = false
|
29
|
-
else
|
30
|
-
config.serve_static_assets = false
|
31
|
-
end
|
32
|
-
|
33
|
-
# Compress JavaScripts and CSS.
|
34
|
-
config.assets.js_compressor = :uglifier
|
35
|
-
# config.assets.css_compressor = :sass
|
36
|
-
|
37
|
-
# Whether to fallback to assets pipeline if a precompiled asset is missed.
|
38
|
-
config.assets.compile = false
|
39
|
-
|
40
|
-
# Generate digests for assets URLs.
|
41
|
-
config.assets.digest = true
|
42
|
-
|
43
|
-
# Version of your assets, change this if you want to expire all your assets.
|
44
|
-
config.assets.version = '1.0'
|
45
|
-
|
46
|
-
# Specifies the header that your server uses for sending files.
|
47
|
-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
48
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
49
|
-
|
50
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
51
|
-
# config.force_ssl = true
|
52
|
-
|
53
|
-
# Set to :debug to see everything in the log.
|
54
|
-
config.log_level = :info
|
55
|
-
|
56
|
-
# Prepend all log lines with the following tags.
|
57
|
-
# config.log_tags = [:subdomain, :uuid]
|
58
|
-
|
59
|
-
# Use a different logger for distributed setups.
|
60
|
-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
61
|
-
|
62
|
-
# Use a different cache store in production.
|
63
|
-
# config.cache_store = :mem_cache_store
|
64
|
-
|
65
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
66
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
67
|
-
|
68
|
-
# Precompile additional assets.
|
69
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
70
|
-
# config.assets.precompile += %w( search.js )
|
71
|
-
|
72
|
-
# Ignore bad email addresses and do not raise email delivery errors.
|
73
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
74
|
-
# config.action_mailer.raise_delivery_errors = false
|
75
|
-
|
76
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
77
|
-
# the I18n.default_locale when a translation can not be found).
|
78
|
-
config.i18n.fallbacks = true
|
79
|
-
|
80
|
-
# Send deprecation notices to registered listeners.
|
81
|
-
config.active_support.deprecation = :notify
|
82
|
-
|
83
|
-
# Disable automatic flushing of the log to improve performance.
|
84
|
-
# config.autoflush_log = false
|
85
|
-
|
86
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
87
|
-
config.log_formatter = ::Logger::Formatter.new
|
88
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RailsApp::Application.configure do
|
4
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
-
|
6
|
-
# The test environment is used exclusively to run your application's
|
7
|
-
# test suite. You never need to work with it otherwise. Remember that
|
8
|
-
# your test database is "scratch space" for the test suite and is wiped
|
9
|
-
# and recreated between test runs. Don't rely on the data there!
|
10
|
-
config.cache_classes = true
|
11
|
-
|
12
|
-
# Do not eager load code on boot. This avoids loading your whole application
|
13
|
-
# just for the purpose of running a single test. If you are using a tool that
|
14
|
-
# preloads Rails for running tests, you may have to set it to true.
|
15
|
-
config.eager_load = false
|
16
|
-
|
17
|
-
# Disable serving static files from the `/public` folder by default since
|
18
|
-
# Apache or NGINX already handles this.
|
19
|
-
if Rails.version >= "5.0.0"
|
20
|
-
config.public_file_server.enabled = true
|
21
|
-
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
|
22
|
-
elsif Rails.version >= "4.2.0"
|
23
|
-
config.serve_static_files = true
|
24
|
-
config.static_cache_control = "public, max-age=3600"
|
25
|
-
else
|
26
|
-
config.serve_static_assets = true
|
27
|
-
config.static_cache_control = "public, max-age=3600"
|
28
|
-
end
|
29
|
-
|
30
|
-
# Show full error reports and disable caching.
|
31
|
-
config.consider_all_requests_local = true
|
32
|
-
config.action_controller.perform_caching = false
|
33
|
-
|
34
|
-
# Raise exceptions instead of rendering exception templates.
|
35
|
-
config.action_dispatch.show_exceptions = false
|
36
|
-
|
37
|
-
# Disable request forgery protection in test environment.
|
38
|
-
config.action_controller.allow_forgery_protection = false
|
39
|
-
|
40
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
41
|
-
# The :test delivery method accumulates sent emails in the
|
42
|
-
# ActionMailer::Base.deliveries array.
|
43
|
-
config.action_mailer.delivery_method = :test
|
44
|
-
|
45
|
-
# Print deprecation notices to the stderr.
|
46
|
-
config.active_support.deprecation = :stderr
|
47
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Be sure to restart your server when you modify this file.
|
4
|
-
|
5
|
-
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
6
|
-
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
7
|
-
|
8
|
-
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
9
|
-
Rails.backtrace_cleaner.remove_silencers!
|
@@ -1,182 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "omniauth-facebook"
|
4
|
-
require "omniauth-openid"
|
5
|
-
|
6
|
-
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
7
|
-
# four configuration values can also be set straight in your models.
|
8
|
-
Devise.setup do |config|
|
9
|
-
config.secret_key = "d9eb5171c59a4c817f68b0de27b8c1e340c2341b52cdbc60d3083d4e8958532" \
|
10
|
-
"18dcc5f589cafde048faec956b61f864b9b5513ff9ce29bf9e5d58b0f234f8e3b"
|
11
|
-
|
12
|
-
# ==> Mailer Configuration
|
13
|
-
# Configure the e-mail address which will be shown in Devise::Mailer,
|
14
|
-
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
15
|
-
config.mailer_sender = "please-change-me@config-initializers-devise.com"
|
16
|
-
|
17
|
-
|
18
|
-
config.parent_controller = "ApplicationWithFakeEngine"
|
19
|
-
# Configure the class responsible to send e-mails.
|
20
|
-
# config.mailer = "Devise::Mailer"
|
21
|
-
|
22
|
-
# ==> ORM configuration
|
23
|
-
# Load and configure the ORM. Supports :active_record (default) and
|
24
|
-
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
25
|
-
# available as additional gems.
|
26
|
-
require "devise/orm/#{DEVISE_ORM}"
|
27
|
-
|
28
|
-
# ==> Configuration for any authentication mechanism
|
29
|
-
# Configure which keys are used when authenticating a user. By default is
|
30
|
-
# just :email. You can configure it to use [:username, :subdomain], so for
|
31
|
-
# authenticating a user, both parameters are required. Remember that those
|
32
|
-
# parameters are used only when authenticating and not when retrieving from
|
33
|
-
# session. If you need permissions, you should implement that in a before filter.
|
34
|
-
# You can also supply hash where the value is a boolean expliciting if authentication
|
35
|
-
# should be aborted or not if the value is not present. By default is empty.
|
36
|
-
# config.authentication_keys = [:email]
|
37
|
-
|
38
|
-
# Configure parameters from the request object used for authentication. Each entry
|
39
|
-
# given should be a request method and it will automatically be passed to
|
40
|
-
# find_for_authentication method and considered in your model lookup. For instance,
|
41
|
-
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
42
|
-
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
43
|
-
# config.request_keys = []
|
44
|
-
|
45
|
-
# Configure which authentication keys should be case-insensitive.
|
46
|
-
# These keys will be downcased upon creating or modifying a user and when used
|
47
|
-
# to authenticate or find a user. Default is :email.
|
48
|
-
config.case_insensitive_keys = [:email]
|
49
|
-
|
50
|
-
# Configure which authentication keys should have whitespace stripped.
|
51
|
-
# These keys will have whitespace before and after removed upon creating or
|
52
|
-
# modifying a user and when used to authenticate or find a user. Default is :email.
|
53
|
-
config.strip_whitespace_keys = [:email]
|
54
|
-
|
55
|
-
# Tell if authentication through request.params is enabled. True by default.
|
56
|
-
# config.params_authenticatable = true
|
57
|
-
|
58
|
-
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
59
|
-
config.http_authenticatable = true
|
60
|
-
|
61
|
-
# If http headers should be returned for AJAX requests. True by default.
|
62
|
-
# config.http_authenticatable_on_xhr = true
|
63
|
-
|
64
|
-
# The realm used in Http Basic Authentication. "Application" by default.
|
65
|
-
# config.http_authentication_realm = "Application"
|
66
|
-
|
67
|
-
# ==> Configuration for :database_authenticatable
|
68
|
-
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
69
|
-
# using other encryptors, it sets how many times you want the password re-encrypted.
|
70
|
-
config.stretches = Rails.env.test? ? 1 : 10
|
71
|
-
|
72
|
-
# ==> Configuration for :confirmable
|
73
|
-
# The time you want to give your user to confirm their account. During this time
|
74
|
-
# they will be able to access your application without confirming. Default is nil.
|
75
|
-
# When allow_unconfirmed_access_for is zero, the user won't be able to sign in without confirming.
|
76
|
-
# You can use this to let your user access some features of your application
|
77
|
-
# without confirming the account, but blocking it after a certain period
|
78
|
-
# (ie 2 days).
|
79
|
-
# config.allow_unconfirmed_access_for = 2.days
|
80
|
-
|
81
|
-
# Defines which key will be used when confirming an account
|
82
|
-
# config.confirmation_keys = [:email]
|
83
|
-
|
84
|
-
# ==> Configuration for :rememberable
|
85
|
-
# The time the user will be remembered without asking for credentials again.
|
86
|
-
# config.remember_for = 2.weeks
|
87
|
-
|
88
|
-
# If true, extends the user's remember period when remembered via cookie.
|
89
|
-
# config.extend_remember_period = false
|
90
|
-
|
91
|
-
# ==> Configuration for :validatable
|
92
|
-
# Range for password length. Default is 8..72.
|
93
|
-
# config.password_length = 8..72
|
94
|
-
|
95
|
-
# Regex to use to validate the email address
|
96
|
-
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
|
97
|
-
|
98
|
-
# ==> Configuration for :timeoutable
|
99
|
-
# The time you want to timeout the user session without activity. After this
|
100
|
-
# time the user will be asked for credentials again. Default is 30 minutes.
|
101
|
-
# config.timeout_in = 30.minutes
|
102
|
-
|
103
|
-
# ==> Configuration for :lockable
|
104
|
-
# Defines which strategy will be used to lock an account.
|
105
|
-
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
106
|
-
# :none = No lock strategy. You should handle locking by yourself.
|
107
|
-
# config.lock_strategy = :failed_attempts
|
108
|
-
|
109
|
-
# Defines which key will be used when locking and unlocking an account
|
110
|
-
# config.unlock_keys = [:email]
|
111
|
-
|
112
|
-
# Defines which strategy will be used to unlock an account.
|
113
|
-
# :email = Sends an unlock link to the user email
|
114
|
-
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
115
|
-
# :both = Enables both strategies
|
116
|
-
# :none = No unlock strategy. You should handle unlocking by yourself.
|
117
|
-
# config.unlock_strategy = :both
|
118
|
-
|
119
|
-
# Number of authentication tries before locking an account if lock_strategy
|
120
|
-
# is failed attempts.
|
121
|
-
# config.maximum_attempts = 20
|
122
|
-
|
123
|
-
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
124
|
-
# config.unlock_in = 1.hour
|
125
|
-
|
126
|
-
# ==> Configuration for :recoverable
|
127
|
-
#
|
128
|
-
# Defines which key will be used when recovering the password for an account
|
129
|
-
# config.reset_password_keys = [:email]
|
130
|
-
|
131
|
-
# Time interval you can reset your password with a reset password key.
|
132
|
-
# Don't put a too small interval or your users won't have the time to
|
133
|
-
# change their passwords.
|
134
|
-
config.reset_password_within = 2.hours
|
135
|
-
|
136
|
-
# When set to false, does not sign a user in automatically after their password is
|
137
|
-
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
138
|
-
# config.sign_in_after_reset_password = true
|
139
|
-
|
140
|
-
# Set up a pepper to generate the encrypted password.
|
141
|
-
config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
|
142
|
-
|
143
|
-
# ==> Scopes configuration
|
144
|
-
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
145
|
-
# "users/sessions/new". It's turned off by default because it's slower if you
|
146
|
-
# are using only default views.
|
147
|
-
# config.scoped_views = false
|
148
|
-
|
149
|
-
# Configure the default scope given to Warden. By default it's the first
|
150
|
-
# devise role declared in your routes (usually :user).
|
151
|
-
# config.default_scope = :user
|
152
|
-
|
153
|
-
# Configure sign_out behavior.
|
154
|
-
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
155
|
-
# The default is true, which means any logout action will sign out all active scopes.
|
156
|
-
# config.sign_out_all_scopes = true
|
157
|
-
|
158
|
-
# ==> Navigation configuration
|
159
|
-
# Lists the formats that should be treated as navigational. Formats like
|
160
|
-
# :html, should redirect to the sign in page when the user does not have
|
161
|
-
# access, but formats like :xml or :json, should return 401.
|
162
|
-
# If you have any extra navigational formats, like :iphone or :mobile, you
|
163
|
-
# should add them to the navigational formats lists. Default is [:html]
|
164
|
-
# config.navigational_formats = [:html, :iphone]
|
165
|
-
|
166
|
-
# The default HTTP method used to sign out a resource. Default is :get.
|
167
|
-
# config.sign_out_via = :get
|
168
|
-
|
169
|
-
# ==> OmniAuth
|
170
|
-
config.omniauth :facebook, 'APP_ID', 'APP_SECRET', scope: 'email,offline_access'
|
171
|
-
config.omniauth :openid
|
172
|
-
config.omniauth :openid, name: 'google', identifier: 'https://www.google.com/accounts/o8/id'
|
173
|
-
|
174
|
-
# ==> Warden configuration
|
175
|
-
# If you want to use other strategies, that are not supported by Devise, or
|
176
|
-
# change the failure app, you can configure them inside the config.warden block.
|
177
|
-
#
|
178
|
-
# config.warden do |manager|
|
179
|
-
# manager.failure_app = AnotherApp
|
180
|
-
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
181
|
-
# end
|
182
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Rails.application.routes.draw do
|
4
|
-
# Resources for testing
|
5
|
-
resources :users, only: [:index] do
|
6
|
-
member do
|
7
|
-
get :expire
|
8
|
-
get :accept
|
9
|
-
get :edit_form
|
10
|
-
put :update_form
|
11
|
-
end
|
12
|
-
|
13
|
-
authenticate do
|
14
|
-
post :exhibit, on: :member
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
resources :admins, only: [:index]
|
19
|
-
|
20
|
-
# Users scope
|
21
|
-
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
22
|
-
|
23
|
-
devise_for :user_on_main_apps,
|
24
|
-
class_name: 'UserOnMainApp',
|
25
|
-
router_name: :main_app,
|
26
|
-
module: :devise
|
27
|
-
|
28
|
-
devise_for :user_on_engines,
|
29
|
-
class_name: 'UserOnEngine',
|
30
|
-
router_name: :fake_engine,
|
31
|
-
module: :devise
|
32
|
-
|
33
|
-
devise_for :user_without_email,
|
34
|
-
class_name: 'UserWithoutEmail',
|
35
|
-
router_name: :main_app,
|
36
|
-
module: :devise
|
37
|
-
|
38
|
-
as :user do
|
39
|
-
get "/as/sign_in", to: "devise/sessions#new"
|
40
|
-
end
|
41
|
-
|
42
|
-
get "/sign_in", to: "devise/sessions#new"
|
43
|
-
|
44
|
-
# Routes for custom controller testing
|
45
|
-
devise_for :user, only: [:registrations], controllers: { registrations: "custom/registrations" }, as: :custom, path: :custom
|
46
|
-
|
47
|
-
# Admin scope
|
48
|
-
devise_for :admin, path: "admin_area", controllers: { sessions: :"admins/sessions" }, skip: :passwords
|
49
|
-
|
50
|
-
get "/admin_area/home", to: "admins#index", as: :admin_root
|
51
|
-
get "/anywhere", to: "foo#bar", as: :new_admin_password
|
52
|
-
|
53
|
-
authenticate(:admin) do
|
54
|
-
get "/private", to: "home#private", as: :private
|
55
|
-
end
|
56
|
-
|
57
|
-
authenticate(:admin, lambda { |admin| admin.active? }) do
|
58
|
-
get "/private/active", to: "home#private", as: :private_active
|
59
|
-
end
|
60
|
-
|
61
|
-
authenticated :admin do
|
62
|
-
get "/dashboard", to: "home#admin_dashboard"
|
63
|
-
end
|
64
|
-
|
65
|
-
authenticated :admin, lambda { |admin| admin.active? } do
|
66
|
-
get "/dashboard/active", to: "home#admin_dashboard"
|
67
|
-
end
|
68
|
-
|
69
|
-
authenticated do
|
70
|
-
get "/dashboard", to: "home#user_dashboard"
|
71
|
-
end
|
72
|
-
|
73
|
-
unauthenticated do
|
74
|
-
get "/join", to: "home#join"
|
75
|
-
end
|
76
|
-
|
77
|
-
# Routes for constraints testing
|
78
|
-
devise_for :headquarters_admin, class_name: "Admin", path: "headquarters", constraints: {host: /192\.168\.1\.\d\d\d/}
|
79
|
-
|
80
|
-
constraints(host: /192\.168\.1\.\d\d\d/) do
|
81
|
-
devise_for :homebase_admin, class_name: "Admin", path: "homebase"
|
82
|
-
end
|
83
|
-
|
84
|
-
scope(subdomain: 'sub') do
|
85
|
-
devise_for :subdomain_users, class_name: "User", only: [:sessions]
|
86
|
-
end
|
87
|
-
|
88
|
-
devise_for :skip_admin, class_name: "Admin", skip: :all
|
89
|
-
|
90
|
-
# Routes for format=false testing
|
91
|
-
devise_for :htmlonly_admin, class_name: "Admin", skip: [:confirmations, :unlocks], path: "htmlonly_admin", format: false, skip_helpers: [:confirmations, :unlocks]
|
92
|
-
devise_for :htmlonly_users, class_name: "User", only: [:confirmations, :unlocks], path: "htmlonly_users", format: false, skip_helpers: true
|
93
|
-
|
94
|
-
# Other routes for routing_test.rb
|
95
|
-
devise_for :reader, class_name: "User", only: :passwords
|
96
|
-
|
97
|
-
scope host: "sub.example.com" do
|
98
|
-
devise_for :sub_admin, class_name: "Admin"
|
99
|
-
end
|
100
|
-
|
101
|
-
namespace :publisher, path_names: { sign_in: "i_dont_care", sign_out: "get_out" } do
|
102
|
-
devise_for :accounts, class_name: "Admin", path_names: { sign_in: "get_in" }
|
103
|
-
end
|
104
|
-
|
105
|
-
scope ":locale", module: :invalid do
|
106
|
-
devise_for :accounts, singular: "manager", class_name: "Admin",
|
107
|
-
path_names: {
|
108
|
-
sign_in: "login", sign_out: "logout",
|
109
|
-
password: "secret", confirmation: "verification",
|
110
|
-
unlock: "unblock", sign_up: "register",
|
111
|
-
registration: "management",
|
112
|
-
cancel: "giveup", edit: "edit/profile"
|
113
|
-
}, failure_app: lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, module: :devise
|
114
|
-
end
|
115
|
-
|
116
|
-
namespace :sign_out_via, module: "devise" do
|
117
|
-
devise_for :deletes, sign_out_via: :delete, class_name: "Admin"
|
118
|
-
devise_for :posts, sign_out_via: :post, class_name: "Admin"
|
119
|
-
devise_for :gets, sign_out_via: :get, class_name: "Admin"
|
120
|
-
devise_for :delete_or_posts, sign_out_via: [:delete, :post], class_name: "Admin"
|
121
|
-
end
|
122
|
-
|
123
|
-
get "/set", to: "home#set"
|
124
|
-
get "/unauthenticated", to: "home#unauthenticated"
|
125
|
-
get "/custom_strategy/new"
|
126
|
-
|
127
|
-
root to: "home#index", via: [:get, :post]
|
128
|
-
end
|
data/test/rails_app/config.ru
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
superclass = ActiveRecord::Migration
|
4
|
-
# TODO: Inherit from the 5.0 Migration class directly when we drop support for Rails 4.
|
5
|
-
superclass = ActiveRecord::Migration[5.0] if superclass.respond_to?(:[])
|
6
|
-
|
7
|
-
class CreateTables < superclass
|
8
|
-
def self.up
|
9
|
-
create_table :users do |t|
|
10
|
-
t.string :username
|
11
|
-
t.string :facebook_token
|
12
|
-
|
13
|
-
## Database authenticatable
|
14
|
-
t.string :email, null: false, default: ""
|
15
|
-
t.string :encrypted_password, null: false, default: ""
|
16
|
-
|
17
|
-
## Recoverable
|
18
|
-
t.string :reset_password_token
|
19
|
-
t.datetime :reset_password_sent_at
|
20
|
-
|
21
|
-
## Rememberable
|
22
|
-
t.datetime :remember_created_at
|
23
|
-
|
24
|
-
## Trackable
|
25
|
-
t.integer :sign_in_count, default: 0
|
26
|
-
t.datetime :current_sign_in_at
|
27
|
-
t.datetime :last_sign_in_at
|
28
|
-
t.string :current_sign_in_ip
|
29
|
-
t.string :last_sign_in_ip
|
30
|
-
|
31
|
-
## Confirmable
|
32
|
-
t.string :confirmation_token
|
33
|
-
t.datetime :confirmed_at
|
34
|
-
t.datetime :confirmation_sent_at
|
35
|
-
# t.string :unconfirmed_email # Only if using reconfirmable
|
36
|
-
|
37
|
-
## Lockable
|
38
|
-
t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts
|
39
|
-
t.string :unlock_token # Only if unlock strategy is :email or :both
|
40
|
-
t.datetime :locked_at
|
41
|
-
|
42
|
-
t.timestamps null: false
|
43
|
-
end
|
44
|
-
|
45
|
-
create_table :admins do |t|
|
46
|
-
## Database authenticatable
|
47
|
-
t.string :email, null: true
|
48
|
-
t.string :encrypted_password, null: true
|
49
|
-
|
50
|
-
## Recoverable
|
51
|
-
t.string :reset_password_token
|
52
|
-
t.datetime :reset_password_sent_at
|
53
|
-
|
54
|
-
## Rememberable
|
55
|
-
t.datetime :remember_created_at
|
56
|
-
|
57
|
-
## Confirmable
|
58
|
-
t.string :confirmation_token
|
59
|
-
t.datetime :confirmed_at
|
60
|
-
t.datetime :confirmation_sent_at
|
61
|
-
t.string :unconfirmed_email # Only if using reconfirmable
|
62
|
-
|
63
|
-
## Lockable
|
64
|
-
t.datetime :locked_at
|
65
|
-
|
66
|
-
## Attribute for testing route blocks
|
67
|
-
t.boolean :active, default: false
|
68
|
-
|
69
|
-
t.timestamps null: false
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.down
|
74
|
-
drop_table :users
|
75
|
-
drop_table :admins
|
76
|
-
end
|
77
|
-
end
|
data/test/rails_app/db/schema.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# This file is auto-generated from the current state of the database. Instead
|
5
|
-
# of editing this file, please use the migrations feature of Active Record to
|
6
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
7
|
-
#
|
8
|
-
# Note that this schema.rb definition is the authoritative source for your
|
9
|
-
# database schema. If you need to create the application database on another
|
10
|
-
# system, you should be using db:schema:load, not running all the migrations
|
11
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
12
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
13
|
-
#
|
14
|
-
# It's strongly recommended that you check this file into your version control system.
|
15
|
-
|
16
|
-
ActiveRecord::Schema.define(version: 20100401102949) do
|
17
|
-
|
18
|
-
create_table "admins", force: true do |t|
|
19
|
-
t.string "email"
|
20
|
-
t.string "encrypted_password"
|
21
|
-
t.string "reset_password_token"
|
22
|
-
t.datetime "reset_password_sent_at"
|
23
|
-
t.datetime "remember_created_at"
|
24
|
-
t.string "confirmation_token"
|
25
|
-
t.datetime "confirmed_at"
|
26
|
-
t.datetime "confirmation_sent_at"
|
27
|
-
t.string "unconfirmed_email"
|
28
|
-
t.datetime "locked_at"
|
29
|
-
t.boolean "active", default: false
|
30
|
-
t.datetime "created_at"
|
31
|
-
t.datetime "updated_at"
|
32
|
-
end
|
33
|
-
|
34
|
-
create_table "users", force: true do |t|
|
35
|
-
t.string "username"
|
36
|
-
t.string "facebook_token"
|
37
|
-
t.string "email", default: "", null: false
|
38
|
-
t.string "encrypted_password", default: "", null: false
|
39
|
-
t.string "reset_password_token"
|
40
|
-
t.datetime "reset_password_sent_at"
|
41
|
-
t.datetime "remember_created_at"
|
42
|
-
t.integer "sign_in_count", default: 0
|
43
|
-
t.datetime "current_sign_in_at"
|
44
|
-
t.datetime "last_sign_in_at"
|
45
|
-
t.string "current_sign_in_ip"
|
46
|
-
t.string "last_sign_in_ip"
|
47
|
-
t.string "confirmation_token"
|
48
|
-
t.datetime "confirmed_at"
|
49
|
-
t.datetime "confirmation_sent_at"
|
50
|
-
t.integer "failed_attempts", default: 0
|
51
|
-
t.string "unlock_token"
|
52
|
-
t.datetime "locked_at"
|
53
|
-
t.datetime "created_at"
|
54
|
-
t.datetime "updated_at"
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SharedAdmin
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
devise :database_authenticatable, :registerable,
|
8
|
-
:timeoutable, :recoverable, :lockable, :confirmable,
|
9
|
-
unlock_strategy: :time, lock_strategy: :none,
|
10
|
-
allow_unconfirmed_access_for: 2.weeks, reconfirmable: true
|
11
|
-
|
12
|
-
validates_length_of :reset_password_token, minimum: 3, allow_blank: true
|
13
|
-
if Devise::Test.rails51?
|
14
|
-
validates_uniqueness_of :email, allow_blank: true, if: :will_save_change_to_email?
|
15
|
-
else
|
16
|
-
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def raw_confirmation_token
|
21
|
-
@raw_confirmation_token
|
22
|
-
end
|
23
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SharedUser
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
8
|
-
:registerable, :rememberable, :timeoutable,
|
9
|
-
:trackable, :validatable, :omniauthable, password_length: 7..72,
|
10
|
-
reconfirmable: false
|
11
|
-
|
12
|
-
attr_accessor :other_key
|
13
|
-
|
14
|
-
# They need to be included after Devise is called.
|
15
|
-
extend ExtendMethods
|
16
|
-
end
|
17
|
-
|
18
|
-
def raw_confirmation_token
|
19
|
-
@raw_confirmation_token
|
20
|
-
end
|
21
|
-
|
22
|
-
module ExtendMethods
|
23
|
-
def new_with_session(params, session)
|
24
|
-
super.tap do |user|
|
25
|
-
if data = session["devise.facebook_data"]
|
26
|
-
user.email = data["email"]
|
27
|
-
user.confirmed_at = Time.now
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|