Module: HubriseApp::ApplicationController::SessionMethods
- Extended by:
- ActiveSupport::Concern
- Included in:
- HubriseApp::ApplicationController
- Defined in:
- app/controllers/hubrise_app/application_controller/session_methods.rb
Instance Method Summary collapse
- #current_user ⇒ Object
- #ensure_authenticated! ⇒ Object
- #logged_in? ⇒ Boolean
- #login(user) ⇒ Object
- #logout ⇒ Object
Instance Method Details
#current_user ⇒ Object
20 21 22 |
# File 'app/controllers/hubrise_app/application_controller/session_methods.rb', line 20 def current_user @current_user ||= User.where(id: session[:user_id]).take end |
#ensure_authenticated! ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/hubrise_app/application_controller/session_methods.rb', line 28 def ensure_authenticated! unless logged_in? redirect_to(build_hubrise_oauth_login_url, allow_other_host: true) return end yield if block_given? end |
#logged_in? ⇒ Boolean
24 25 26 |
# File 'app/controllers/hubrise_app/application_controller/session_methods.rb', line 24 def logged_in? !!current_user end |
#login(user) ⇒ Object
11 12 13 14 |
# File 'app/controllers/hubrise_app/application_controller/session_methods.rb', line 11 def login(user) session[:user_id] = user.id @current_user = user end |
#logout ⇒ Object
16 17 18 |
# File 'app/controllers/hubrise_app/application_controller/session_methods.rb', line 16 def logout session[:user_id] = nil end |