]> source.dussan.org Git - redmine.git/commitdiff
Don't let users log time on issues they cannot see in their projects (#21150).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Nov 2015 18:40:15 +0000 (18:40 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 4 Nov 2015 18:40:15 +0000 (18:40 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14796 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb
app/views/timelog/_form.html.erb
test/functional/timelog_controller_test.rb

index b133f502af2accb05547561defa4e660d22c99e6..ea33c0bc693b5c6d55087362cf9a09ce2aeb646a 100644 (file)
@@ -95,7 +95,7 @@ class TimeEntry < ActiveRecord::Base
     if attrs
       attrs = super(attrs)
       if issue_id_changed? && issue
-        if user.allowed_to?(:log_time, issue.project)
+        if issue.visible?(user) && user.allowed_to?(:log_time, issue.project)
           if attrs[:project_id].blank? && issue.project_id != project_id
             self.project_id = issue.project_id
           end
index 0dbff35a7edf9e729577f37d52206e389ffa4437..ac6ba915477e321534509bffd7cff9ba43c4f549 100644 (file)
@@ -13,7 +13,9 @@
   <% end %>
   <p>
     <%= f.text_field :issue_id, :size => 6 %>
-    <span id="time_entry_issue"><%= "#{@time_entry.issue.tracker.name} ##{@time_entry.issue.id}: #{@time_entry.issue.subject}" if @time_entry.issue.try(:visible?) %></span>
+    <% if @time_entry.issue.try(:visible?) %>
+      <span id="time_entry_issue"><%= "#{@time_entry.issue.tracker.name} ##{@time_entry.issue.id}: #{@time_entry.issue.subject}" %></span>
+    <% end %>
   </p>
   <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
   <p><%= f.text_field :hours, :size => 6, :required => true %></p>
index 68fde87f0b6b8c359d8b2a51f4aa88222243e4a1..7ce39caab0c858efa471c429de6c0337c9013100 100644 (file)
@@ -219,6 +219,23 @@ class TimelogControllerTest < ActionController::TestCase
     end
   end
 
+  def test_create_on_issue_that_is_not_visible_should_not_disclose_subject
+    issue = Issue.generate!(:subject => "issue_that_is_not_visible", :is_private => true)
+    assert !issue.visible?(User.find(3))
+
+    @request.session[:user_id] = 3
+    assert_no_difference 'TimeEntry.count' do
+      post :create, :time_entry => {
+        :project_id => '', :issue_id => issue.id.to_s,
+        :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+      }
+    end
+    assert_select_error /Issue is invalid/
+    assert_select "input[name=?][value=?]", "time_entry[issue_id]", issue.id.to_s
+    assert_select "#time_entry_issue", 0
+    assert !response.body.include?('issue_that_is_not_visible')
+  end
+
   def test_create_and_continue_at_project_level
     @request.session[:user_id] = 2
     assert_difference 'TimeEntry.count' do