diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-11 14:17:12 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-02-11 14:17:12 +0100 |
commit | a231215ec2b547e44092afa347f4739c72dea97f (patch) | |
tree | f86e0295bbba069afd085a674352014a73014208 | |
parent | 8b5d920b54f89cb29f1b40df465d70c217cd07e6 (diff) | |
download | sonarqube-a231215ec2b547e44092afa347f4739c72dea97f.tar.gz sonarqube-a231215ec2b547e44092afa347f4739c72dea97f.zip |
Do not fail when session is expired when browsing a private dashboard
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 62c6456e142..40981b63a1c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -29,13 +29,20 @@ class DashboardController < ApplicationController load_resource() load_dashboard() load_authorized_widget_definitions() + unless @dashboard + redirect_to home_path + end end def configure # TODO display error page if no dashboard or no resource load_resource() load_dashboard() - load_widget_definitions() + load_widget_definitions() + unless @dashboard + redirect_to home_path + end + end def edit_layout @@ -169,7 +176,7 @@ class DashboardController < ApplicationController end end @dashboard=(@active ? @active.dashboard : nil) - @dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :period_index => params[:period], :snapshot => @snapshot) + @dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :period_index => params[:period], :snapshot => @snapshot) if @dashboard && @snapshot end def load_resource @@ -185,16 +192,18 @@ class DashboardController < ApplicationController end def load_authorized_widget_definitions() - @widget_definitions = java_facade.getWidgets(@resource.scope, @resource.qualifier, @resource.language) - @widget_definitions=@widget_definitions.select do |widget| - authorized=widget.getUserRoles().size==0 - unless authorized - widget.getUserRoles().each do |role| - authorized=(role=='user') || (role=='viewer') || has_role?(role, @resource) - break if authorized + if @resource + @widget_definitions = java_facade.getWidgets(@resource.scope, @resource.qualifier, @resource.language) + @widget_definitions=@widget_definitions.select do |widget| + authorized=widget.getUserRoles().size==0 + unless authorized + widget.getUserRoles().each do |role| + authorized=(role=='user') || (role=='viewer') || has_role?(role, @resource) + break if authorized + end end + authorized end - authorized end end |