Class: SimpleAuth::ActionController::RequireLoginAction

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_auth/action_controller/require_login_action.rb

Constant Summary collapse

DEFAULT_UNLOGGED_IN_MESSAGE =
"You must be logged in to access this page."
DEFAULT_UNAUTHORIZED_MESSAGE =
"You don't have permission to access this page."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, scope) ⇒ RequireLoginAction

Returns a new instance of RequireLoginAction.



9
10
11
12
# File 'lib/simple_auth/action_controller/require_login_action.rb', line 9

def initialize(controller, scope)
  @controller = controller
  @scope = scope
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



7
8
9
# File 'lib/simple_auth/action_controller/require_login_action.rb', line 7

def controller
  @controller
end

#scopeObject (readonly)

Returns the value of attribute scope.



7
8
9
# File 'lib/simple_auth/action_controller/require_login_action.rb', line 7

def scope
  @scope
end

Instance Method Details

#messageObject



18
19
20
21
22
# File 'lib/simple_auth/action_controller/require_login_action.rb', line 18

def message
  return nil if valid?
  return unauthorized_message unless authorized?
  unlogged_message
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/simple_auth/action_controller/require_login_action.rb', line 14

def valid?
  valid_session? && authorized?
end