Change the default route to the login page
[cs356-p2-videostore.git] / app / controllers / application.rb
index 4e5f623..aaf37b3 100644 (file)
@@ -3,5 +3,22 @@
 
 class ApplicationController < ActionController::Base
   # Pick a unique cookie name to distinguish our session data from others'
-  session :session_key => '_try5_session_id'
+  session :session_key => '_prippropprix_session_id'
+
+  private
+
+  def authorize
+    unless User.find_by_id(session[:user_id])
+      flash[:notice] = "Please log in"
+      redirect_to :controller => "login", :action => "login"
+    end
+  end
+
+  def manager
+    user = User.find_by_id(session[:user_id])
+    unless user and user.manager
+      flash[:notice] = "You must be a manager to access this page"
+      redirect_to :controller => "login", :action => "index"
+    end
+  end
 end