Module: Devise::Failure
- Defined in:
- lib/devise/failure.rb
Class Method Summary collapse
-
.call(env) ⇒ Object
Failure application that will be called every time :warden is thrown from any strategy or hook.
Class Method Details
.call(env) ⇒ Object
Failure application that will be called every time :warden is thrown from any strategy or hook. Responsible for redirect the user to the sign in page based on current scope and mapping. If no scope is given, redirect to the default_url.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/devise/failure.rb', line 9 def self.call(env) = env['warden.options'] scope = [:scope] params = case env['warden'].try(:message) when Symbol { env['warden']. => true } when String { :message => env['warden']. } else [:params] end env['warden'].logout redirect_path = if mapping = Devise.mappings[scope] "#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}" else "/#{default_url}" end headers = {} headers["Location"] = redirect_path headers["Location"] << "?" << Rack::Utils.build_query(params) if params headers["Content-Type"] = 'text/plain' = [:message] || "You are being redirected to #{redirect_path}" [302, headers, []] end |