Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Add role-based authorization for updating teams

Andras Bacsai36c31dcd6777
diff --git a/app/Models/Team.php b/app/Models/Team.php
index a3dd4e473b..e08ba7f5b1 100644
--- a/app/Models/Team.php
+++ b/app/Models/Team.php
@@ -21,9 +21,11 @@ class Team extends Model implements SendsDiscord, SendsEmail
protected static function booted()
{
- // static::saved(function () {
- // refreshSession();
- // });
+ static::saving(function ($team) {
+ if (auth()->user()->isMember()) {
+ throw new \Exception('You are not allowed to update this team.');
+ }
+ });
}
public function routeNotificationForDiscord()
diff --git a/app/Models/User.php b/app/Models/User.php
index e2ecae56a9..0fa8ead2f2 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -127,6 +127,10 @@ class User extends Authenticatable implements SendsEmail
{
return $this->role() === 'owner';
}
+ public function isMember()
+ {
+ return $this->role() === 'member';
+ }
public function isAdminFromSession()
{
if (auth()->user()->id === 0) {