Skip to content

Commit

Permalink
Prevent subscibing to internal components when not logged in
Browse files Browse the repository at this point in the history
Fixes #2520
  • Loading branch information
jbrooksuk committed Jun 24, 2017
1 parent 20baf42 commit f3df8b4
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions app/Http/Controllers/SubscribeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use CachetHQ\Cachet\Models\Subscription;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
Expand All @@ -37,6 +38,25 @@
*/
class SubscribeController extends Controller
{
/**
* The illuminate guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;

/**
* Create a new subscribe controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}

/**
* Show the subscribe by email page.
*
Expand Down Expand Up @@ -146,10 +166,12 @@ public function showManage($code = null)
throw new NotFoundHttpException();
}

$includePrivate = $this->auth->check();

$subscriber = Subscriber::where('verify_code', '=', $code)->first();
$usedComponentGroups = Component::enabled()->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
$usedComponentGroups = Component::enabled()->authenticated($includePrivate)->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::enabled()->where('group_id', '=', 0)->orderBy('order')->orderBy('created_at')->get();
$ungroupedComponents = Component::enabled()->authenticated($includePrivate)->where('group_id', '=', 0)->orderBy('order')->orderBy('created_at')->get();

if (!$subscriber) {
throw new BadRequestHttpException();
Expand Down

0 comments on commit f3df8b4

Please sign in to comment.