feat(usermanagement): ubah respons abort menjadi JSON untuk akses terlarang di beberapa controller
- Mengganti respons `abort(403)` menjadi respons JSON yang lebih informatif di beberapa controller:
- **PermissionsController**
- Penyesuaian pada metode penghapusan dan pengambilan data untuk datatable.
- Menampilkan pesan error dan status success=false jika pengguna tidak memiliki izin.
- **PositionsController**
- Perubahan serupa diterapkan pada metode penghapusan posisi dan pengambilan data untuk datatable.
- **RolesController**
- Penyesuaian dilakukan pada metode pengambilan data untuk datatable.
- **UsersController**
- Ubah logika pada metode penghapusan dan pengambilan data pengguna ke JSON.
Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -170,7 +170,7 @@
|
||||
{
|
||||
// Check if the authenticated user has the required permission to delete positions
|
||||
if (is_null($this->user) || !$this->user->can('usermanagement.delete')) {
|
||||
abort(403, 'Sorry! You are not allowed to delete positions.');
|
||||
return response()->json(['message' => 'Sorry! You are not allowed to delete positions.','success' => false]);
|
||||
}
|
||||
|
||||
// Find the position by ID
|
||||
@@ -207,7 +207,7 @@
|
||||
{
|
||||
// Check if the authenticated user has the required permission to view positions
|
||||
if (is_null($this->user) || !$this->user->can('usermanagement.read')) {
|
||||
abort(403, 'Sorry! You are not allowed to view positions.');
|
||||
return response()->json(['message' => 'Sorry! You are not allowed to view positions.','success' => false]);
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
|
||||
Reference in New Issue
Block a user