fix(biometrics): ensure company admin and superadmin accounts have full biometric attendance visibility
This commit is contained in:
@@ -153,12 +153,14 @@ class BiometricAttendanceController extends Controller
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (!Auth::user()->can('manage-biometric-attendance') && !Auth::user()->can('view-biometric-attendance')) {
|
||||
$user = Auth::user();
|
||||
$isSuperOrCompany = in_array($user->type, ['company', 'superadmin']);
|
||||
|
||||
if (!$isSuperOrCompany && !$user->can('manage-biometric-attendance') && !$user->can('view-biometric-attendance') && !$user->can('manage-any-biometric-attendance') && !$user->can('manage-own-biometric-attendance')) {
|
||||
return redirect()->back()->with('error', __('Permission Denied.'));
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$canManageAny = $user->can('manage-any-biometric-attendance');
|
||||
$canManageAny = $isSuperOrCompany || $user->can('manage-any-biometric-attendance');
|
||||
$canManageBranch = $user->can('manage-biometric-attendance');
|
||||
|
||||
$query = \App\Models\BiometricAttendance::with(['branch']);
|
||||
@@ -175,12 +177,7 @@ class BiometricAttendanceController extends Controller
|
||||
->orWhereIn('biometric_emp_id', $branchEmpCodes);
|
||||
});
|
||||
} else {
|
||||
$biometricEmpId = $user->employee?->biometric_emp_id;
|
||||
if (!empty($biometricEmpId)) {
|
||||
$query->where('biometric_emp_id', $biometricEmpId);
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
// Manager without a specific branch assigned has company-wide management
|
||||
}
|
||||
} else {
|
||||
// Self-service: only own biometric details
|
||||
@@ -314,14 +311,16 @@ class BiometricAttendanceController extends Controller
|
||||
{
|
||||
try {
|
||||
$user = Auth::user();
|
||||
if (!$user->can('view-biometric-attendance') && !$user->can('manage-biometric-attendance') && !$user->can('manage-any-biometric-attendance')) {
|
||||
$isSuperOrCompany = in_array($user->type, ['company', 'superadmin']);
|
||||
|
||||
if (!$isSuperOrCompany && !$user->can('view-biometric-attendance') && !$user->can('manage-biometric-attendance') && !$user->can('manage-any-biometric-attendance') && !$user->can('manage-own-biometric-attendance')) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Permission denied'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$canManageAny = $user->can('manage-any-biometric-attendance');
|
||||
$canManageAny = $isSuperOrCompany || $user->can('manage-any-biometric-attendance');
|
||||
$canManageBranch = $user->can('manage-biometric-attendance');
|
||||
|
||||
// If user is a self-service employee only, verify they are viewing their own record
|
||||
|
||||
Reference in New Issue
Block a user