diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -2,7 +2,7 @@ before_filter :authenticate - verify :method => :post, :only => [:test_submit], + verify :method => :post, :only => [:submit], :redirect_to => { :action => :index } def index @@ -24,8 +24,12 @@ def read user = User.find(session[:user_id]) - test_request = TestRequest.find(params[:id]) - if test_request.user_id != user.id + begin + test_request = TestRequest.find(params[:id]) + rescue + test_request = nil + end + if test_request==nil or test_request.user_id != user.id flash[:notice] = 'Invalid output' redirect_to :action => 'index' return @@ -42,6 +46,20 @@ end redirect_to :action => 'index' end + + def result + @user = User.find(session[:user_id]) + begin + @test_request = TestRequest.find(params[:id]) + rescue + @test_request = nil + end + if @test_request==nil or @test_request.user_id != @user.id + flash[:notice] = 'Invalid request' + redirect_to :action => 'index' + return + end + end protected