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 Attribute Summary collapse
-
#email_method ⇒ Object
Returns the value of attribute email_method.
-
#logout_method ⇒ Object
Returns the value of attribute logout_method.
-
#logout_path ⇒ Object
Returns the value of attribute logout_path.
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 Attribute Details
#email_method ⇒ Object
Returns the value of attribute email_method.
5 6 7 |
# File 'lib/wallaby/configuration/security.rb', line 5 def email_method @email_method end |
#logout_method ⇒ Object
Returns the value of attribute logout_method.
5 6 7 |
# File 'lib/wallaby/configuration/security.rb', line 5 def logout_method @logout_method end |
#logout_path ⇒ Object
Returns the value of attribute logout_path.
5 6 7 |
# File 'lib/wallaby/configuration/security.rb', line 5 def logout_path @logout_path end |
Instance Method Details
#authenticate(&block) ⇒ Object
Configure how to authenicate a user. All application controller methods will be available.
47 48 49 50 51 52 53 |
# File 'lib/wallaby/configuration/security.rb', line 47 def authenticate(&block) if block_given? @authenticate = block else @authenticate ||= DEFAULT_AUTHENTICATE end end |
#authenticate? ⇒ Boolean
See if authenticate configuration is set
57 58 59 |
# File 'lib/wallaby/configuration/security.rb', line 57 def authenticate? authenticate != DEFAULT_AUTHENTICATE end |
#current_user(&block) ⇒ Object
Configure how to get the current user. All application controller methods will be available.
21 22 23 24 25 26 27 |
# File 'lib/wallaby/configuration/security.rb', line 21 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
31 32 33 |
# File 'lib/wallaby/configuration/security.rb', line 31 def current_user? current_user != DEFAULT_CURRENT_USER end |