module ActionDispatch::Cookies::VerifyAndUpgradeLegacySignedMessage

def initialize(*args)

:nodoc:
opportunity to detect and migrate legacy cookies.
(de)serialization step within the cookie jar, which gives us the
to the Message{Encryptor,Verifier} allows us to handle the
Passing the ActiveSupport::MessageEncryptor::NullSerializer downstream
def initialize(*args)
  super
  @legacy_verifier = ActiveSupport::MessageVerifier.new(request.secret_token, serializer: ActiveSupport::MessageEncryptor::NullSerializer)
end

def parse(name, signed_message)

def parse(name, signed_message)
  super || verify_and_upgrade_legacy_signed_message(name, signed_message)
end

def verify_and_upgrade_legacy_signed_message(name, signed_message)

def verify_and_upgrade_legacy_signed_message(name, signed_message)
  deserialize(name, @legacy_verifier.verify(signed_message)).tap do |value|
    self[name] = { value: value }
  end
rescue ActiveSupport::MessageVerifier::InvalidSignature
  nil
end