diff options
| author | mo khan <mo@mokhan.ca> | 2014-08-13 21:00:14 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-08-13 21:00:14 -0600 |
| commit | c716f5d96f1a5540c432f68b42273c1b91bc7065 (patch) | |
| tree | 1f102903f935b38524f3e315494270c568d9318e /app/controllers/application_controller.rb | |
| parent | 9d2a55ad41010c50b046cd23fd4cdf237fad481f (diff) | |
fix broken tests.
Diffstat (limited to 'app/controllers/application_controller.rb')
| -rw-r--r-- | app/controllers/application_controller.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 12e48976..15c32e3b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,9 +4,18 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_filter :load_header before_filter :configure_permitted_parameters, if: :devise_controller? + helper_method :current_user, :user_signed_in? + + def user_session(session_id = cookies.signed[:cookie_monster]) + Session.find_by(id: session_id) + end def current_user - @session.try(:user) + user_session.try(:user) + end + + def user_signed_in? + current_user end protected @@ -25,8 +34,6 @@ class ApplicationController < ActionController::Base end def authenticate! - @session = Session.find_by(id: cookies.signed[:cookie_monster]) - redirect_to new_session_path unless @session + redirect_to new_session_path unless user_session end - end |
