Module: Ramaze::Helper::Access
- Defined in:
- lib/zen/package/users/lib/users/helper/access.rb
Overview
Whenever this module is included into a controller all its methods require the user to be logged in. If you want to make certain methods available to non logged in users you can do so using ClassMethods#allow:
class Users < Zen::Controller::AdminController
allow [:login]
def login
end
end
Defined Under Namespace
Modules: ClassMethods
Constant Summary
- PUBLIC_ACTIONS =
Hash containing various controllers and methods that the user can access without logging in.
{}
Class Method Summary (collapse)
-
+ (Object) add_block(klass)
Adds the stacked block to a given class.
-
+ (Object) included(into)
Called whenever this module is included into a controller.
Class Method Details
+ (Object) add_block(klass)
Adds the stacked block to a given class.
since 0.3
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/zen/package/users/lib/users/helper/access.rb', line 39 def self.add_block(klass) klass.stacked_before_all(:validate_user_login) do deny = true klass = self.class method = action.method if method method = method.to_sym if PUBLIC_ACTIONS.key?(klass) \ and PUBLIC_ACTIONS[klass].include?(method) deny = false end if deny == true and logged_in? == false (:error, lang('zen_general.errors.require_login')) redirect(::Users::Controller::Users.r(:login)) end end end end |
+ (Object) included(into)
Called whenever this module is included into a controller.
29 30 31 |
# File 'lib/zen/package/users/lib/users/helper/access.rb', line 29 def self.included(into) into.extend(ClassMethods) end |