Skip to content

Commit 19d6daf

Browse files
committed
Fix paste visibility on project level.
1 parent 9eebf3b commit 19d6daf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

app/models/paste.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,22 @@ class Paste < ActiveRecord::Base
3636
scope :unexpired, where("expires_at IS NULL OR expires_at > current_timestamp")
3737

3838
#
39-
# * Restrict to projects where the user is a member with a role
40-
# allowing to view pastes.
39+
# * Restrict to projects where the user has a role allowing to view
40+
# pastes.
4141
#
4242
# * Restrict to specific project, if given.
4343
#
44-
# * Admin users should be able to see all pastes, even secure ones)
44+
# * Admin users should be able to see all pastes, even secure ones.
4545
#
4646
# * An ordinary user can see a secure paste only if he has authored it.
4747
#
4848
# * Never show expired pastes even to an admin.
4949
#
5050
scope :visible, lambda{ |user=User.current, *args|
5151
o = args.first || {}
52-
o = o.merge(:member => true)
5352

54-
s = self
53+
s = where(Project.allowed_to_condition(user, :view_pastes, o)).includes(:project)
5554
unless user.admin?
56-
s = s.where(Project.allowed_to_condition(user, :view_pastes, o)).includes(:project)
5755
s = s.where(["access_token IS NULL OR author_id = ?", user.id])
5856
end
5957
s.unexpired

0 commit comments

Comments
 (0)