X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=app%2Fcontrollers%2Fapplication.rb;h=fe5e10108c6b113c81ebd84c398559c229a91534;hb=893fb158ba822c7ce7f5b3d011a2401e7f974f50;hp=8dfb326615c1fcb91584d95547e664b886173461;hpb=09cd438e77dd418b03b67e3e6a4b48ec95b72d1d;p=depot.git diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 8dfb326..fe5e101 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -2,14 +2,25 @@ # 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 # Uncomment the :secret if you're not using the cookie session store - protect_from_forgery # :secret => 'd7e9713fb540572dab37a045152d442a' + protect_from_forgery :secret => 'd7e9713fb540572dab37a045152d442a' # See ActionController::Base for details # 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