3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 02:35:24 +00:00

Warn if user has individual permission overrides

This commit is contained in:
snipe
2025-10-25 18:57:17 +01:00
parent 4a5bf78d58
commit df68dca9dc
2 changed files with 22 additions and 2 deletions

View File

@ -224,6 +224,24 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
return false;
}
public function hasIndividualPermissions() {
if (is_object($this->permissions)) {
$permissions = json_decode(json_encode($this->permissions), true);
}
if (is_string($this->permissions)) {
$permissions = json_decode($this->permissions, true);
}
foreach ($permissions as $permission) {
if ($permission != 0) {
return true;
}
}
return false;
}
/**
* Internally check the user permission for the given section
*

View File

@ -426,17 +426,19 @@
<div class="col-md-9">
@if ($user->groups->count() > 0)
@foreach ($user->groups as $group)
@can('superadmin')
<a href="{{ route('groups.show', $group->id) }}" class="label label-default">{{ $group->name }}</a>
@else
{{ $group->name }}
@endcan
@endforeach
@else
--
@endif
@if ($user->hasIndividualPermissions())
<span class="text-warning"><x-icon type="warning" />This user has at least one individual permission set.</span>
@endif
</div>
</div>