mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
Enforce forum.view permission
This commit is contained in:
parent
3f0089e8bb
commit
ff8dc5ef25
|
@ -56,7 +56,7 @@ class ShowAction extends SerializeResourceAction
|
||||||
{
|
{
|
||||||
$forum = app('flarum.forum');
|
$forum = app('flarum.forum');
|
||||||
|
|
||||||
$forum->groups = Group::all();
|
$forum->groups = Group::whereVisibleTo($request->actor)->get();
|
||||||
|
|
||||||
return $forum;
|
return $forum;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class ForumSerializer extends Serializer
|
||||||
'welcomeTitle' => Core::config('welcome_title'),
|
'welcomeTitle' => Core::config('welcome_title'),
|
||||||
'welcomeMessage' => Core::config('welcome_message'),
|
'welcomeMessage' => Core::config('welcome_message'),
|
||||||
'themePrimaryColor' => Core::config('theme_primary_color'),
|
'themePrimaryColor' => Core::config('theme_primary_color'),
|
||||||
|
'canView' => $forum->can($this->actor, 'view'),
|
||||||
'canStartDiscussion' => $forum->can($this->actor, 'startDiscussion')
|
'canStartDiscussion' => $forum->can($this->actor, 'startDiscussion')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ trait VisibleScope
|
||||||
*/
|
*/
|
||||||
public function scopeWhereVisibleTo(Builder $query, User $actor)
|
public function scopeWhereVisibleTo(Builder $query, User $actor)
|
||||||
{
|
{
|
||||||
event(new ScopeModelVisibility($this, $query, $actor));
|
if (! app('flarum.forum')->can($actor, 'view')) {
|
||||||
|
$query->whereRaw('FALSE');
|
||||||
|
} else {
|
||||||
|
event(new ScopeModelVisibility($this, $query, $actor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user