X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=app%2Fcontrollers%2Fapplication.rb;h=fe5e10108c6b113c81ebd84c398559c229a91534;hb=942d6c5b97e90c2c9036d1ec776ca98584e5be8f;hp=fea87e2d210d5e5dfe122bfcc526fb008889ab8c;hpb=128ba7d3b10ef93d000a3f6105c09129bf84b991;p=depot.git diff --git a/app/controllers/application.rb b/app/controllers/application.rb index fea87e2..fe5e101 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -2,6 +2,8 @@ # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base + layout "store" + before_filter :authorize, :except => :login helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for details @@ -12,4 +14,13 @@ class ApplicationController < ActionController::Base # Uncomment this to filter the contents of submitted sensitive data parameters # from your application log (in this case, all fields with names like "password"). # filter_parameter_logging :password + + protected + def authorize + unless User.find_by_id(session[:user_id]) + session[:original_uri] = request.request_uri + flash[:notice] = "Please log in" + redirect_to :controller => 'admin', 'action' => 'login' + end + end end