Module: Outpost::Controller::Authentication
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- lib/outpost/controller/authentication.rb
Instance Method Summary collapse
-
#current_user ⇒ Object
Public: The currently logged-in user.
-
#require_login ⇒ Object
Private: Callback to require login.
Instance Method Details
#current_user ⇒ Object
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_login ⇒ Object
Private: Callback to require login.
Returns nothing.
27 28 29 30 31 32 |
# File 'lib/outpost/controller/authentication.rb', line 27 def require_login if !current_user session[:return_to] = request.fullpath redirect_to outpost.login_path and return false end end |