Files
devise/test/rails_app/lib/shared_admin.rb
Carlos Antonio da Silva 367ea42762 Refactor dirty tracking conditionals for different versions (#5575)
We have an number of conditions due to how dirty tracking changed around
Rails 5.1, that implement methods using one or another method call. I
might need more of this for mongo upgrades based on an initial
investigation, plus this makes the code really hard to reason about
sometimes with these many conditionals.

While I want to drop support for older versions of Rails soon, this
centralization of dirty methods that are used by devise conditionally
simplifies the usage considerably across the board, moves the version
condition to a single place, and will make it easier to refactor later
once we drop older Rails version by simply removing the `devise_*`
versions of the methods, alongside the prefix on the method calls for
the most part, since those methods follow the naming of the newer Rails
versions.
2023-03-23 19:11:11 -03:00

20 lines
591 B
Ruby

# frozen_string_literal: true
module SharedAdmin
extend ActiveSupport::Concern
included do
devise :database_authenticatable, :registerable,
:timeoutable, :recoverable, :lockable, :confirmable,
unlock_strategy: :time, lock_strategy: :none,
allow_unconfirmed_access_for: 2.weeks, reconfirmable: true
validates_length_of :reset_password_token, minimum: 3, allow_blank: true
validates_uniqueness_of :email, allow_blank: true, if: :devise_will_save_change_to_email?
end
def raw_confirmation_token
@raw_confirmation_token
end
end