Class: Devise::FailureApp
- Inherits:
-
ActionController::Metal
- Object
- ActionController::Metal
- Devise::FailureApp
show all
- Includes:
- ActionController::RackDelegation, ActionController::Redirecting, ActionController::UrlFor, Controllers::SharedHelpers
- 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.
Constant Summary
Controllers::SharedHelpers::MIME_REFERENCES
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.call(env) ⇒ Object
17
18
19
20
|
# File 'lib/devise/failure_app.rb', line 17
def self.call(env)
@respond ||= action(:respond)
@respond.call(env)
end
|
.default_url_options(*args) ⇒ Object
22
23
24
|
# File 'lib/devise/failure_app.rb', line 22
def self.default_url_options(*args)
ApplicationController.default_url_options(*args)
end
|
Instance Method Details
#http_auth ⇒ Object
36
37
38
39
40
41
|
# File 'lib/devise/failure_app.rb', line 36
def http_auth
self.status = 401
self.["WWW-Authenticate"] = %(Basic realm=#{Devise.http_authentication_realm.inspect}) if
self.content_type = request.format.to_s
self.response_body = http_auth_body
end
|
#recall ⇒ Object
43
44
45
46
47
|
# File 'lib/devise/failure_app.rb', line 43
def recall
env["PATH_INFO"] = attempted_path
flash.now[:alert] = i18n_message(:invalid)
self.response = recall_app(warden_options[:recall]).call(env)
end
|
#redirect ⇒ Object
49
50
51
52
53
|
# File 'lib/devise/failure_app.rb', line 49
def redirect
store_location!
flash[:alert] = i18n_message
redirect_to redirect_url
end
|
#respond ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/devise/failure_app.rb', line 26
def respond
if http_auth?
http_auth
elsif warden_options[:recall]
recall
else
redirect
end
end
|