feat: implement authorization checks for various requests in academic and user management
This commit is contained in:
parent
23961969f4
commit
86ea75ec91
@ -9,7 +9,7 @@ class AssignmentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-assignments' : 'update-assignments');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class AttendanceStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('create-attendances');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class MaterialRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-materials' : 'update-materials');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class ScheduleRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-schedules' : 'update-schedules');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class SubmissionRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-assignment-submissions' : 'update-assignment-submissions');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class UpdateRolePermissionsRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('update-roles');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class TuitionInvoiceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-tuition-invoices' : 'update-tuition-invoices');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class TuitionPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-tuition-payments' : 'update-tuition-payments');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class AnnouncementRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-announcements' : 'update-announcements');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class ClassEnrollmentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('create-course-class-enrollments');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -11,7 +11,7 @@ class CourseClassRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-course-classes' : 'update-course-classes');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -12,7 +12,7 @@ class CourseRegistrationRequest extends FormRequest
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (! $this->routeIs('student.*')) {
|
||||
return true;
|
||||
return $this->user()->can('create-course-registrations');
|
||||
}
|
||||
|
||||
$student = $this->user()->student;
|
||||
|
||||
@ -8,7 +8,7 @@ class RejectCourseRegistrationRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('reject-course-registrations');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class AcademicTermRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-academic-terms' : 'update-academic-terms');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class CourseRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-courses' : 'update-courses');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -9,7 +9,7 @@ class DepartmentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-departments' : 'update-departments');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -13,7 +13,7 @@ public function authorize(): bool
|
||||
return (bool) $this->user()->lecturer;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-academic-advising-logs' : 'update-academic-advising-logs');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -14,7 +14,7 @@ public function authorize(): bool
|
||||
return (bool) $this->user()->student;
|
||||
}
|
||||
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-letter-requests' : 'update-letter-requests');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -8,7 +8,15 @@ class UpdateStatusRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
$permission = match ($this->route()?->getName()) {
|
||||
'admin.master.academic-terms.update_status' => 'update-academic-terms-status',
|
||||
'admin.users.lecturers.update_user_status' => 'update-lecturers-status',
|
||||
'admin.users.students.update_user_status' => 'update-students-account-status',
|
||||
'admin.users.administrators.update_user_status' => 'update-administrators-status',
|
||||
default => null,
|
||||
};
|
||||
|
||||
return $permission !== null && $this->user()->can($permission);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class AdministratorRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-administrators' : 'update-administrators');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class LecturerRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-lecturers' : 'update-lecturers');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -11,7 +11,7 @@ class StudentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can($this->isMethod('post') ? 'create-students' : 'update-students');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
@ -10,7 +10,7 @@ class StudentStatusRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->user()->can('update-students-academic-status');
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
||||
Loading…
Reference in New Issue
Block a user