mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Prevent owner user from being deleted
This commit is contained in:
parent
87bbeeb67e
commit
3ebcbc034e
@ -196,7 +196,7 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function destroy(DestroyUserRequest $request, User $user)
|
||||
{
|
||||
if ($user->isOwner()) {
|
||||
if ($user->hasOwnerFlag()) {
|
||||
return response()->json(['message', 'Cannot detach owner.'], 401);
|
||||
}
|
||||
|
||||
|
@ -372,9 +372,12 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
public function isOwner() : bool
|
||||
{
|
||||
return $this->token()->cu->is_owner;
|
||||
|
||||
}
|
||||
|
||||
public function hasOwnerFlag(): bool
|
||||
{
|
||||
return $this->company_users()->where('is_owner',true)->exists();
|
||||
}
|
||||
/**
|
||||
* Returns true is user is an admin _or_ owner
|
||||
*
|
||||
|
@ -120,7 +120,7 @@ class UserRepository extends BaseRepository
|
||||
|
||||
public function destroy(array $data, User $user)
|
||||
{
|
||||
if ($user->isOwner()) {
|
||||
if ($user->hasOwnerFlag()) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user