Class: Marley::Plugins::CurrentUserMethods

Inherits:
Plugin show all
Defined in:
lib/marley/joints/user.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Method Summary collapse

Methods inherited from Plugin

#config, #initialize

Methods included from Utils::ClassAttrs

#class_attr, #lazy_class_attrs

Constructor Details

This class inherits a constructor from Marley::Plugins::Plugin

Instance Method Details

#apply(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/marley/joints/user.rb', line 6

def apply(*args)
  super
  if @opts[:http_auth]
    Marley.config(:authenticate => lambda { |env|
      require 'rack/auth/basic'
      auth =  Rack::Auth::Basic::Request.new(env)
      if (auth.provided? && auth.basic? && auth.credentials)
        $request[:user]=MR::User.authenticate(auth.credentials)
        raise AuthenticationError unless $request[:user]
      else
        $request[:user]=MR::User.new
      end
    })
  end
end