From 8fe658bacc2697ec37c21f13908178be3ee294a3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 Apr 2024 18:34:33 +0200 Subject: [PATCH 1/2] fix: members cannot manage subscriptions --- app/Livewire/Subscription/Index.php | 3 +++ app/Livewire/Subscription/Show.php | 3 +++ config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Subscription/Index.php b/app/Livewire/Subscription/Index.php index 1444187ac..6c1d8e66c 100644 --- a/app/Livewire/Subscription/Index.php +++ b/app/Livewire/Subscription/Index.php @@ -15,6 +15,9 @@ public function mount() if (!isCloud()) { return redirect(RouteServiceProvider::HOME); } + if (auth()->user()->isMember()) { + return redirect()->route('dashboard'); + } if (data_get(currentTeam(), 'subscription') && isSubscriptionActive()) { return redirect()->route('subscription.show'); } diff --git a/app/Livewire/Subscription/Show.php b/app/Livewire/Subscription/Show.php index ad677ce53..413997464 100644 --- a/app/Livewire/Subscription/Show.php +++ b/app/Livewire/Subscription/Show.php @@ -11,6 +11,9 @@ public function mount() if (!isCloud()) { return redirect()->route('dashboard'); } + if (auth()->user()->isMember()) { + return redirect()->route('dashboard'); + } if (!data_get(currentTeam(), 'subscription')) { return redirect()->route('subscription.index'); } diff --git a/config/sentry.php b/config/sentry.php index 9561601c1..a3fbc0a3a 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.250', + 'release' => '4.0.0-beta.251', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index bcd3a45f5..d88e65a1b 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Fri, 5 Apr 2024 18:47:07 +0200 Subject: [PATCH 2/2] fix: isMember --- app/Livewire/Subscription/Index.php | 2 +- app/Livewire/Subscription/Show.php | 2 +- app/Models/Team.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Subscription/Index.php b/app/Livewire/Subscription/Index.php index 6c1d8e66c..b367e6dcc 100644 --- a/app/Livewire/Subscription/Index.php +++ b/app/Livewire/Subscription/Index.php @@ -15,7 +15,7 @@ public function mount() if (!isCloud()) { return redirect(RouteServiceProvider::HOME); } - if (auth()->user()->isMember()) { + if (auth()->user()?->isMember()) { return redirect()->route('dashboard'); } if (data_get(currentTeam(), 'subscription') && isSubscriptionActive()) { diff --git a/app/Livewire/Subscription/Show.php b/app/Livewire/Subscription/Show.php index 413997464..2ae89806d 100644 --- a/app/Livewire/Subscription/Show.php +++ b/app/Livewire/Subscription/Show.php @@ -11,7 +11,7 @@ public function mount() if (!isCloud()) { return redirect()->route('dashboard'); } - if (auth()->user()->isMember()) { + if (auth()->user()?->isMember()) { return redirect()->route('dashboard'); } if (!data_get(currentTeam(), 'subscription')) { diff --git a/app/Models/Team.php b/app/Models/Team.php index e08ba7f5b..29e434a5d 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -22,7 +22,7 @@ class Team extends Model implements SendsDiscord, SendsEmail protected static function booted() { static::saving(function ($team) { - if (auth()->user()->isMember()) { + if (auth()->user()?->isMember()) { throw new \Exception('You are not allowed to update this team.'); } });