Class: Authlogic::ControllerAdapters::AbstractAdapter
- Inherits:
-
Object
- Object
- Authlogic::ControllerAdapters::AbstractAdapter
show all
- Defined in:
- lib/authlogic/controller_adapters/abstract_adapter.rb
Overview
Allows you to use Authlogic in any framework you want, not just rails. See the RailsAdapter for an example of how to adapt Authlogic to work with your framework.
Constant Summary
collapse
- E_COOKIE_DOMAIN_ADAPTER =
"The cookie_domain method has not been " \
"implemented by the controller adapter".freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of AbstractAdapter.
11
12
13
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 11
def initialize(controller)
self.controller = controller
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args, &block) ⇒ Object
90
91
92
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 90
def method_missing(id, *args, &block)
controller.send(id, *args, &block)
end
|
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
9
10
11
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 9
def controller
@controller
end
|
Instance Method Details
#authenticate_with_http_basic ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 15
def authenticate_with_http_basic
@auth = Rack::Auth::Basic::Request.new(controller.request.env)
if @auth.provided? && @auth.basic?
yield(*@auth.credentials)
else
false
end
end
|
#cookie_domain ⇒ Object
28
29
30
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 28
def cookie_domain
raise NotImplementedError.new(E_COOKIE_DOMAIN_ADAPTER)
end
|
#cookies ⇒ Object
24
25
26
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 24
def cookies
controller.cookies
end
|
#last_request_update_allowed? ⇒ Boolean
You can disable the updating of ‘last_request_at` on a per-controller basis.
def last_request_update_allowed?
false
end
For example, what if you had a javascript function that polled the server updating how much time is left in their session before it times out. Obviously you would want to ignore this request, because then the user would never time out. So you can do something like this in your controller:
def last_request_update_allowed?
action_name != "update_session_time_left"
end
See ‘authlogic/session/magic_columns.rb` to learn more about the `last_request_at` column itself.
76
77
78
79
80
81
82
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 76
def last_request_update_allowed?
if controller.respond_to?(:last_request_update_allowed?, true)
controller.send(:last_request_update_allowed?)
else
true
end
end
|
#params ⇒ Object
32
33
34
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 32
def params
controller.params
end
|
#request ⇒ Object
36
37
38
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 36
def request
controller.request
end
|
#request_content_type ⇒ Object
40
41
42
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 40
def request_content_type
request.content_type
end
|
#respond_to_missing?(*args) ⇒ Boolean
84
85
86
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 84
def respond_to_missing?(*args)
super(*args) || controller.respond_to?(*args)
end
|
#responds_to_single_access_allowed? ⇒ Boolean
48
49
50
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 48
def responds_to_single_access_allowed?
controller.respond_to?(:single_access_allowed?, true)
end
|
#session ⇒ Object
44
45
46
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 44
def session
controller.session
end
|
#single_access_allowed? ⇒ Boolean
52
53
54
|
# File 'lib/authlogic/controller_adapters/abstract_adapter.rb', line 52
def single_access_allowed?
controller.send(:single_access_allowed?)
end
|