Class: Wallaby::Configuration::Security
- Inherits:
-
Object
- Object
- Wallaby::Configuration::Security
- Defined in:
- lib/wallaby/configuration/security.rb
Overview
Security configuration
Constant Summary collapse
- DEFAULT_CURRENT_USER =
by default, current_user returns nil
-> { nil }
- DEFAULT_AUTHENTICATE =
by default, not to stop the before_action chain
-> { true }
Instance Method Summary collapse
-
#authenticate(&block) ⇒ Object
Configure how to authenicate a user.
-
#authenticate? ⇒ Boolean
See if authenticate configuration is set.
-
#current_user(&block) ⇒ Object
Configure how to get the current user.
-
#current_user? ⇒ Boolean
See if current_user configuration is set.
Instance Method Details
#authenticate(&block) ⇒ Object
Configure how to authenicate a user. All application controller methods will be available.
46 47 48 49 50 51 52 |
# File 'lib/wallaby/configuration/security.rb', line 46 def authenticate(&block) if block_given? @authenticate = block else @authenticate ||= DEFAULT_AUTHENTICATE end end |
#authenticate? ⇒ Boolean
See if authenticate configuration is set
56 57 58 |
# File 'lib/wallaby/configuration/security.rb', line 56 def authenticate? authenticate != DEFAULT_AUTHENTICATE end |
#current_user(&block) ⇒ Object
Configure how to get the current user. All application controller methods will be available.
20 21 22 23 24 25 26 |
# File 'lib/wallaby/configuration/security.rb', line 20 def current_user(&block) if block_given? @current_user = block else @current_user ||= DEFAULT_CURRENT_USER end end |
#current_user? ⇒ Boolean
See if current_user configuration is set
30 31 32 |
# File 'lib/wallaby/configuration/security.rb', line 30 def current_user? current_user != DEFAULT_CURRENT_USER end |