feat(acl): Change views/backend code to able to use proper ACL's later on. Currently it is not enabled.
This commit is contained in:
@@ -4,16 +4,21 @@ namespace App\Livewire\Team;
|
||||
|
||||
use App\Enums\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Livewire\Component;
|
||||
|
||||
class Member extends Component
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
public User $member;
|
||||
|
||||
public function makeAdmin()
|
||||
{
|
||||
try {
|
||||
$this->authorize('manageMembers', currentTeam());
|
||||
|
||||
if (Role::from(auth()->user()->role())->lt(Role::ADMIN)
|
||||
|| Role::from($this->getMemberRole())->gt(auth()->user()->role())) {
|
||||
throw new \Exception('You are not authorized to perform this action.');
|
||||
@@ -28,6 +33,8 @@ class Member extends Component
|
||||
public function makeOwner()
|
||||
{
|
||||
try {
|
||||
$this->authorize('manageMembers', currentTeam());
|
||||
|
||||
if (Role::from(auth()->user()->role())->lt(Role::OWNER)
|
||||
|| Role::from($this->getMemberRole())->gt(auth()->user()->role())) {
|
||||
throw new \Exception('You are not authorized to perform this action.');
|
||||
@@ -42,6 +49,8 @@ class Member extends Component
|
||||
public function makeReadonly()
|
||||
{
|
||||
try {
|
||||
$this->authorize('manageMembers', currentTeam());
|
||||
|
||||
if (Role::from(auth()->user()->role())->lt(Role::ADMIN)
|
||||
|| Role::from($this->getMemberRole())->gt(auth()->user()->role())) {
|
||||
throw new \Exception('You are not authorized to perform this action.');
|
||||
@@ -56,6 +65,8 @@ class Member extends Component
|
||||
public function remove()
|
||||
{
|
||||
try {
|
||||
$this->authorize('manageMembers', currentTeam());
|
||||
|
||||
if (Role::from(auth()->user()->role())->lt(Role::ADMIN)
|
||||
|| Role::from($this->getMemberRole())->gt(auth()->user()->role())) {
|
||||
throw new \Exception('You are not authorized to perform this action.');
|
||||
|
||||
Reference in New Issue
Block a user