Module: PagesCore::Authentication

Extended by:
ActiveSupport::Concern
Included in:
BaseController
Defined in:
app/controllers/concerns/pages_core/authentication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_userObject (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.

Returns:

  • (Boolean)

15
16
17
# File 'app/controllers/concerns/pages_core/authentication.rb', line 15

def logged_in?
  current_user ? true : false
end