Don't let users view discussions without permission

closes #599
This commit is contained in:
Toby Zerner 2015-10-22 21:52:15 +10:30
parent 73c02f66e7
commit d6691e6299

View File

@ -69,7 +69,9 @@ class DiscussionPolicy extends AbstractPolicy
*/
public function find(User $actor, Builder $query)
{
if (! $actor->hasPermission('discussion.hide')) {
if (! $actor->hasPermission('viewDiscussions')) {
$query->whereRaw('FALSE');
} elseif (! $actor->hasPermission('discussion.hide')) {
$query->where(function ($query) use ($actor) {
$query->whereNull('discussions.hide_time')
->where('comments_count', '>', 0)