-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add specialized timeline authorizer, refactor timeline controller, ex…
…pose read-only timelines to contributors
- Loading branch information
Showing
5 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class TimelineAuthorizer < ContentAuthorizer | ||
def self.creatable_by?(user) | ||
return false unless user.present? | ||
return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email) | ||
|
||
return true if user.on_premium_plan? | ||
end | ||
|
||
def readable_by?(user) | ||
return true if resource.privacy == 'public' | ||
return true if user && resource.user_id == user.id | ||
return true if resource.universe.present? && resource.universe.privacy == 'public' | ||
return true if user && resource.universe.present? && resource.universe.user_id == user.id | ||
return true if user && resource.universe.present? && resource.universe.contributors.pluck(:user_id).include?(user.id) | ||
return true if user && user.site_administrator? | ||
|
||
return false | ||
end | ||
|
||
def updatable_by?(user) | ||
[ | ||
user && resource.user_id == user.id | ||
].any? | ||
end | ||
|
||
def deletable_by?(user) | ||
[ | ||
user && resource.user_id == user.id | ||
].any? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters