Module: PagesCore::Authentication
- Extended by:
- ActiveSupport::Concern
- Included in:
- BaseController
- Defined in:
- app/controllers/concerns/pages_core/authentication.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the current user if logged in, or nil.
Instance Method Summary collapse
- #authenticate!(user) ⇒ Object
- #deauthenticate! ⇒ Object
-
#logged_in? ⇒ Boolean
Returns true if the user is logged in.
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the current user if logged in, or nil.
12 13 14 |
# File 'app/controllers/concerns/pages_core/authentication.rb', line 12 def current_user @current_user end |
Instance Method Details
#authenticate!(user) ⇒ Object
19 20 21 22 |
# File 'app/controllers/concerns/pages_core/authentication.rb', line 19 def authenticate!(user) user.mark_active! @current_user = user end |
#deauthenticate! ⇒ Object
24 25 26 27 |
# File 'app/controllers/concerns/pages_core/authentication.rb', line 24 def deauthenticate! @current_user = nil session[:current_user_id] = nil end |
#logged_in? ⇒ Boolean
Returns true if the user is logged in.
15 16 17 |
# File 'app/controllers/concerns/pages_core/authentication.rb', line 15 def logged_in? current_user ? true : false end |