== Module ==
# User authentication mixin for use with Rails controllers.
module UserAuthentication
# Requires that a user is logged in.
def authentication_required(options = {})
before_filter :authentication_required_filter, options
end
# ...snip other methods.
end
== Controller ==
require_dependency "user_authentication"
class UsersController < ApplicationController
include UserAuthentication
authentication_required :except => "login"
role_required :admin, :only => [ "edit", "update", "destroy" ]
def index
list
render :action => 'list'
end
# ... snip other methods
end