Add role-based authorization for updating teams
This commit is contained in:
@@ -21,9 +21,11 @@ class Team extends Model implements SendsDiscord, SendsEmail
|
|||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
// static::saved(function () {
|
static::saving(function ($team) {
|
||||||
// refreshSession();
|
if (auth()->user()->isMember()) {
|
||||||
// });
|
throw new \Exception('You are not allowed to update this team.');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routeNotificationForDiscord()
|
public function routeNotificationForDiscord()
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ class User extends Authenticatable implements SendsEmail
|
|||||||
{
|
{
|
||||||
return $this->role() === 'owner';
|
return $this->role() === 'owner';
|
||||||
}
|
}
|
||||||
|
public function isMember()
|
||||||
|
{
|
||||||
|
return $this->role() === 'member';
|
||||||
|
}
|
||||||
public function isAdminFromSession()
|
public function isAdminFromSession()
|
||||||
{
|
{
|
||||||
if (auth()->user()->id === 0) {
|
if (auth()->user()->id === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user