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.



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

def current_user
  @current_user
end

Instance Method Details

#authenticate!(user) ⇒ Object



21
22
23
24
# File 'app/controllers/concerns/pages_core/authentication.rb', line 21

def authenticate!(user)
  reset_session
  authenticated(user)
end

#deauthenticate!Object



26
27
28
29
# File 'app/controllers/concerns/pages_core/authentication.rb', line 26

def deauthenticate!
  @current_user = nil
  reset_session
end

#logged_in?Boolean

Returns true if the user is logged in.

Returns:

  • (Boolean)


17
18
19
# File 'app/controllers/concerns/pages_core/authentication.rb', line 17

def logged_in?
  current_user ? true : false
end