Class: Devise::FailureApp
- Inherits:
-
ActionController::Metal
- Object
- ActionController::Metal
- Devise::FailureApp
- Includes:
- ActionController::RackDelegation, ActionController::Redirecting, ActionController::UrlFor
- Defined in:
- lib/devise/failure_app.rb
Overview
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.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(env) ⇒ Object
16 17 18 |
# File 'lib/devise/failure_app.rb', line 16 def self.call(env) action(:respond).call(env) end |
.default_url_options(*args) ⇒ Object
20 21 22 |
# File 'lib/devise/failure_app.rb', line 20 def self.(*args) ApplicationController.(*args) end |
Instance Method Details
#http_auth ⇒ Object
34 35 36 37 38 39 |
# File 'lib/devise/failure_app.rb', line 34 def http_auth self.status = 401 self.headers["WWW-Authenticate"] = %(Basic realm=#{Devise.http_authentication_realm.inspect}) self.content_type = request.format.to_s self.response_body = http_auth_body end |
#recall ⇒ Object
41 42 43 44 45 |
# File 'lib/devise/failure_app.rb', line 41 def recall env["PATH_INFO"] = attempted_path flash.now[:alert] = (:invalid) self.response = recall_controller.action([:recall]).call(env) end |
#redirect ⇒ Object
47 48 49 50 51 |
# File 'lib/devise/failure_app.rb', line 47 def redirect store_location! flash[:alert] = unless flash[:notice] redirect_to redirect_url end |
#respond ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/devise/failure_app.rb', line 24 def respond if http_auth? http_auth elsif [:recall] recall else redirect end end |