Standardised admin role check
This commit is contained in:
parent
3eb2246291
commit
0c1b1cd435
2 changed files with 4 additions and 4 deletions
|
@ -39,11 +39,11 @@ class DeleteUsers extends Command{
|
||||||
$numDeleted = 0;
|
$numDeleted = 0;
|
||||||
if (strtolower(trim($confirm)) === 'yes')
|
if (strtolower(trim($confirm)) === 'yes')
|
||||||
{
|
{
|
||||||
$totalUsers = User::count();
|
$totalUsers = $this->user->count();
|
||||||
$users = $this->user->where('system_name', '=', null)->with('roles')->get();
|
$users = $this->user->where('system_name', '=', null)->with('roles')->get();
|
||||||
foreach ($users as $user)
|
foreach ($users as $user)
|
||||||
{
|
{
|
||||||
if ($user->hasRole('admin'))
|
if ($user->hasSystemRole('admin'))
|
||||||
{
|
{
|
||||||
// don't delete users with "admin" role
|
// don't delete users with "admin" role
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -115,9 +115,9 @@ class UserRepo
|
||||||
*/
|
*/
|
||||||
public function isOnlyAdmin(User $user)
|
public function isOnlyAdmin(User $user)
|
||||||
{
|
{
|
||||||
if (!$user->roles->pluck('name')->contains('admin')) return false;
|
if (!$user->hasSystemRole('admin')) return false;
|
||||||
|
|
||||||
$adminRole = $this->role->getRole('admin');
|
$adminRole = $this->role->getSystemRole('admin');
|
||||||
if ($adminRole->users->count() > 1) return false;
|
if ($adminRole->users->count() > 1) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue