Module: ActionDispatch::Cookies::VerifyAndUpgradeLegacySignedMessage

Included in:
UpgradeLegacyEncryptedCookieJar, UpgradeLegacySignedCookieJar
Defined in:
lib/action_dispatch/middleware/cookies.rb

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object



176
177
178
179
# File 'lib/action_dispatch/middleware/cookies.rb', line 176

def initialize(*args)
  super
  @legacy_verifier = ActiveSupport::MessageVerifier.new(@options[:secret_token])
end

#verify_and_upgrade_legacy_signed_message(name, signed_message) ⇒ Object



181
182
183
184
185
186
187
# File 'lib/action_dispatch/middleware/cookies.rb', line 181

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