Module: Outpost::Controller::Authentication

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
lib/outpost/controller/authentication.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject

Public: The currently logged-in user.

Returns Outpost.user_class instance.



14
15
16
17
18
19
20
21
22
# File 'lib/outpost/controller/authentication.rb', line 14

def current_user
  begin
    @current_user ||= Outpost.user_class
      .where(can_login: true).find(session[:user_id])
  rescue ActiveRecord::RecordNotFound
    session[:user_id]   = nil
    @current_user       = nil
  end
end

#require_loginObject

Private: Callback to require login.

Returns nothing.



27
28
29
30
31
32
# File 'lib/outpost/controller/authentication.rb', line 27

def 
  if !current_user
    session[:return_to] = request.fullpath
    redirect_to outpost. and return false
  end
end