diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..8b351d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,13 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + before_action :configure_permitted_parameters, if: :devise_controller? + + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) + devise_parameter_sanitizer.permit(:account_update, keys: [:name]) + end + end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index ccd2f9d..d82b399 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -4,19 +4,22 @@ # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. - # Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key` + # Devise will use the `secret_key_base` as its `secret_key` # by default. You can change it below and use your own secret key. - # config.secret_key = 'db05481326e0188a6a3c501f68b4463bf0cf37a28c1b9c802bb1ee57bda10dcc51d9d1d653622ad34660acea896d71cdc52841949642994edccfddb38e1d7b3c' + # config.secret_key = '1d6afd1dba918f0f6f4580889cbaef479ed3979191ab75015e3a5b083473b2f34ca03b43ec19bff4fe5c462e19c49ae262e1001b4ee9edb67f4e4de6cd0199d0' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name.to_s # fix for Issue #11 + config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' + # Configure the parent class responsible to send e-mails. + # config.parent_mailer = 'ActionMailer::Base' + # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be @@ -87,19 +90,28 @@ # from the server. You can disable this option at your own risk. # config.clean_up_csrf_token_on_authentication = true + # When false, Devise will not attempt to reload routes on eager load. + # This can reduce the time taken to boot the app but if your application + # requires the Devise mappings to be loaded during boot time the application + # won't boot properly. + # config.reload_routes = true + # ==> Configuration for :database_authenticatable - # For bcrypt, this is the cost for hashing the password and defaults to 10. If - # using other encryptors, it sets how many times you want the password re-encrypted. + # For bcrypt, this is the cost for hashing the password and defaults to 11. If + # using other algorithms, it sets how many times you want the password to be hashed. # # Limiting the stretches to just one in testing will increase the performance of # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use # a value less than 10 in other environments. Note that, for bcrypt (the default - # encryptor), the cost increases exponentially with the number of stretches (e.g. + # algorithm), the cost increases exponentially with the number of stretches (e.g. # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). - config.stretches = Rails.env.test? ? 1 : 10 + config.stretches = Rails.env.test? ? 1 : 11 + + # Set up a pepper to generate the hashed password. + # config.pepper = '31b4bf97e36f40360541acc20b2156d35473af42494777299f5163192bac27840508b433202860d37721303a8910a6482aa7d344ae50d33bddcc6718d7af2d9b' - # Setup a pepper to generate the encrypted password. - # config.pepper = '2932b36d40b6551deeaf1575651a03173e8315efe57fae0f044dbbe56020942b7ef8bfb4c448de29a38a9d8c72da41a4382684ce438a67ddbf895a84427405a9' + # Send a notification email when the user's password is changed + # config.send_password_change_notification = false # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without @@ -142,12 +154,12 @@ # ==> Configuration for :validatable # Range for password length. - config.password_length = 8..72 + config.password_length = 6..128 # Email regex used to validate email formats. It simply asserts that # one (and only one) @ exists in the given string. This is mainly # to give user feedback and not to assert the e-mail validity. - # config.email_regexp = /\A[^@]+@[^@]+\z/ + config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this @@ -195,11 +207,11 @@ # config.sign_in_after_reset_password = true # ==> Configuration for :encryptable - # Allow you to use another encryption algorithm besides bcrypt (default). You can use - # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, - # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) - # and :restful_authentication_sha1 (then you should set stretches to 10, and copy - # REST_AUTH_SITE_KEY to pepper). + # Allow you to use another hashing or encryption algorithm besides bcrypt (default). + # You can use :sha1, :sha512 or algorithms from others authentication tools as + # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 + # for default behavior) and :restful_authentication_sha1 (then you should set + # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). # # Require the `devise-encryptable` gem when using anything other than bcrypt # config.encryptor = :sha512 diff --git a/config/initializers/devise_permitted_parameters.rb b/config/initializers/devise_permitted_parameters.rb deleted file mode 100644 index cbbee2a..0000000 --- a/config/initializers/devise_permitted_parameters.rb +++ /dev/null @@ -1,17 +0,0 @@ -module DevisePermittedParameters - extend ActiveSupport::Concern - - included do - before_action :configure_permitted_parameters - end - - protected - - def configure_permitted_parameters - devise_parameter_sanitizer.for(:sign_up) << :name - devise_parameter_sanitizer.for(:account_update) << :name - end - -end - -DeviseController.send :include, DevisePermittedParameters diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 26a10f2..bd4c3eb 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -23,6 +23,8 @@ en: subject: "Reset password instructions" unlock_instructions: subject: "Unlock instructions" + password_change: + subject: "Password Changed" omniauth_callbacks: failure: "Could not authenticate you from %{kind} because \"%{reason}\"." success: "Successfully authenticated from %{kind} account."