Permalink
Browse files

merb?

  • Loading branch information...
1 parent 2459dad commit 769744c41a1463d3f023d70939fc700ee86f7bde @binarylogic committed Dec 9, 2012
View
11 lib/authlogic.rb
@@ -6,20 +6,20 @@
"i18n",
"random",
"regex",
-
+
"controller_adapters/abstract_adapter",
-
+
"crypto_providers/md5",
"crypto_providers/sha1",
"crypto_providers/sha256",
"crypto_providers/sha512",
"crypto_providers/bcrypt",
"crypto_providers/aes256",
"crypto_providers/scrypt",
-
+
"authenticates_many/base",
"authenticates_many/association",
-
+
"acts_as_authentic/email",
"acts_as_authentic/logged_in_status",
"acts_as_authentic/login",
@@ -32,7 +32,7 @@
"acts_as_authentic/single_access_token",
"acts_as_authentic/validations_scope",
"acts_as_authentic/base",
-
+
"session/activation",
"session/active_record_trickery",
"session/brute_force_protection",
@@ -61,5 +61,4 @@
end
require AUTHLOGIC_PATH + "controller_adapters/rails_adapter" if defined?( Rails )
-require AUTHLOGIC_PATH + "controller_adapters/merb_adapter" if defined?( Merb )
require AUTHLOGIC_PATH + "controller_adapters/sinatra_adapter" if defined?( Sinatra )
View
18 lib/authlogic/controller_adapters/abstract_adapter.rb
@@ -1,14 +1,14 @@
module Authlogic
module ControllerAdapters # :nodoc:
- # Allows you to use Authlogic in any framework you want, not just rails. See the RailsAdapter or MerbAdapter
+ # 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.
class AbstractAdapter
attr_accessor :controller
def initialize(controller)
self.controller = controller
end
-
+
def authenticate_with_http_basic(&block)
@auth = Rack::Auth::Basic::Request.new(controller.request.env)
if @auth.provided? and @auth.basic?
@@ -17,11 +17,11 @@ def authenticate_with_http_basic(&block)
false
end
end
-
+
def cookies
controller.cookies
end
-
+
def cookie_domain
raise NotImplementedError.new("The cookie_domain method has not been implemented by the controller adapter")
end
@@ -41,23 +41,23 @@ def request_content_type
def session
controller.session
end
-
+
def responds_to_single_access_allowed?
controller.respond_to?(:single_access_allowed?, true)
end
-
+
def single_access_allowed?
controller.send(:single_access_allowed?)
end
-
+
def responds_to_last_request_update_allowed?
controller.respond_to?(:last_request_update_allowed?, true)
end
-
+
def last_request_update_allowed?
controller.send(:last_request_update_allowed?)
end
-
+
private
def method_missing(id, *args, &block)
controller.send(id, *args, &block)
View
30 lib/authlogic/controller_adapters/merb_adapter.rb
@@ -1,30 +0,0 @@
-module Authlogic
- module ControllerAdapters
- # Adapts authlogic to work with merb. The point is to close the gap between what authlogic expects and what the merb controller object
- # provides. Similar to how ActiveRecord has an adapter for MySQL, PostgreSQL, SQLite, etc.
- class MerbAdapter < AbstractAdapter
- # Lets Authlogic know about the controller object via a before filter, AKA "activates" authlogic.
- module MerbImplementation
- def self.included(klass) # :nodoc:
- klass.before :activate_authlogic
- end
-
- def cookie_domain
- Merb::Config[:session_cookie_domain]
- end
-
- private
- def activate_authlogic
- Authlogic::Session::Base.controller = MerbAdapter.new(self)
- end
- end
- end
- end
-end
-
-# make sure we're running inside Merb
-if defined?(Merb::Plugins)
- Merb::BootLoader.before_app_loads do
- Merb::Controller.send(:include, Authlogic::ControllerAdapters::MerbAdapter::MerbImplementation)
- end
-end

0 comments on commit 769744c

Please sign in to comment.