uploads: only let users see their own uploads on /uploads listing.

This commit is contained in:
evazion
2020-04-06 14:12:57 -05:00
parent b2ee1f0766
commit 1e0f6f730a
4 changed files with 17 additions and 3 deletions

View File

@@ -82,6 +82,16 @@ class Upload < ApplicationRecord
where("created_at < ?", date).lock.destroy_all
end
def self.visible(user)
if user.is_admin?
all
elsif user.is_member?
where(uploader: user)
else
none
end
end
module FileMethods
def is_image?
%w(jpg gif png).include?(file_ext)