Class: Devise::CookieSanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/rails/warden_compat.rb

Overview

Solve a bug in Rails where Set-Cookie is returning an array.

Constant Summary collapse

"Set-Cookie".freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CookieSanitizer

Returns a new instance of CookieSanitizer.



38
39
40
# File 'lib/devise/rails/warden_compat.rb', line 38

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/devise/rails/warden_compat.rb', line 42

def call(env)
  response = @app.call(env)
  headers = response[1]
  cookies = headers[SET_COOKIE]
  if cookies.respond_to?(:join)
    headers[SET_COOKIE] = cookies.join("\n").squeeze("\n")
  end
  response
end