Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x feature -> 2.x develop | Updated: permission denied response #242

Merged
merged 168 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
01059da
Updated: setup configuration and account page
we-vikram-wri231 Dec 30, 2023
59753e3
Updated: env app name to session prefix and session cookie
we-vikram-wri231 Dec 30, 2023
f751d53
Updated: rebuild assets
we-vikram-wri231 Dec 30, 2023
880270d
Updated: restricted action
we-vikram-wri231 Dec 30, 2023
06f45e8
Updated: restricted action in bulk action
we-vikram-wri231 Dec 30, 2023
f0a0697
Updated: restricted action
we-vikram-wri231 Dec 30, 2023
56e1d4c
Fixed: permission seeds of taxonomy section
we-vikram-wri231 Dec 30, 2023
65855d8
Updated: restricted action for bulk action
we-vikram-wri231 Dec 30, 2023
5db5249
Updated: Active all logic
we-vikram-wri231 Dec 30, 2023
04e11d4
Fixed: role permission active all logic
we-vikram-wri231 Dec 30, 2023
fee0a59
Updated: validation and placeholder text
we-vikram-wri231 Jan 3, 2024
49948b2
Updated: rebuild assets
we-vikram-wri231 Jan 3, 2024
eaf3bac
Updated: language string of label
we-alam-a001 Jan 4, 2024
d14427a
Updated: setup configuration and account page
we-vikram-wri231 Dec 30, 2023
9def8d7
Updated: env app name to session prefix and session cookie
we-vikram-wri231 Dec 30, 2023
7f97cf8
Updated: rebuild assets
we-vikram-wri231 Dec 30, 2023
2192d6d
Updated: validation and placeholder text
we-vikram-wri231 Jan 3, 2024
a25e661
Updated: rebuild assets
we-vikram-wri231 Jan 3, 2024
280e6b3
Merge remote-tracking branch 'origin/2.x-feature/session-fixes' into …
we-vikram-wri231 Jan 4, 2024
616a6e8
Updated: localization of dashboard page
we-alam-a001 Jan 4, 2024
2e507db
Updated: sidebar menu label extend and dashboard
we-alam-a001 Jan 4, 2024
dc686ff
Added: conditional if for language string
we-alam-a001 Jan 4, 2024
39accb1
Fixed: login error while language is fr
we-alam-a001 Jan 4, 2024
0e7a2c2
Updated: extend controller for label
we-alam-a001 Jan 4, 2024
f9aca85
Fixed: to show bold text
we-alam-a001 Jan 5, 2024
233ab41
Updated: sidebar menu label extend and dashboard
we-alam-a001 Jan 5, 2024
f677137
Merge remote-tracking branch 'origin/2.x-feature/update-dashbaord-loc…
we-alam-a001 Jan 5, 2024
ccf53dc
Updated: dashboard language string
we-alam-a001 Jan 5, 2024
0b79f93
Removed: unused line
we-alam-a001 Jan 5, 2024
cc2a2c5
Updated: restricted action
we-vikram-wri231 Dec 30, 2023
c81b95e
Updated: restricted action in bulk action
we-vikram-wri231 Dec 30, 2023
5dd3e50
Updated: restricted action
we-vikram-wri231 Dec 30, 2023
13fcb46
Fixed: permission seeds of taxonomy section
we-vikram-wri231 Dec 30, 2023
39ef299
Updated: restricted action for bulk action
we-vikram-wri231 Dec 30, 2023
1cc03d2
Updated: Active all logic
we-vikram-wri231 Dec 30, 2023
41c85d3
Fixed: role permission active all logic
we-vikram-wri231 Dec 30, 2023
e4d40d4
Merge remote-tracking branch 'origin/2.x-feature/added-restricted-act…
we-vikram-wri231 Jan 6, 2024
297c4cf
Updated: view role bulk function
we-vikram-wri231 Jan 6, 2024
d81f670
Updated: bulk all condition
we-vikram-wri231 Jan 6, 2024
aad4ff7
Updated: roles bulk actions
we-vikram-wri231 Jan 6, 2024
14b2e80
Updated: permission denied response
we-vikram-wri231 Jan 6, 2024
66185ea
Updated: registrations permission denied response
we-alam-a001 Jan 6, 2024
43bf19a
Updated: haspermission param
we-vikram-wri231 Jan 6, 2024
2dcdd79
Updated: users permission denied response
we-alam-a001 Jan 6, 2024
5389ad0
Updated: all haspermission param
we-alam-a001 Jan 6, 2024
8446f86
Updated: permission denied response in roles
we-alam-a001 Jan 6, 2024
db9e927
Updated: permission denied response in permissions
we-alam-a001 Jan 6, 2024
83634ef
Updated: permission denied response in modules
we-alam-a001 Jan 6, 2024
94f05fb
Updated: media permission denied response
we-alam-a001 Jan 8, 2024
76a0fd8
Updated: taxonomies permission denied response
we-alam-a001 Jan 8, 2024
fe7a98c
Updated: themes permission denied response
we-alam-a001 Jan 8, 2024
df57e6f
Updated: advanced permission denied response
we-alam-a001 Jan 8, 2024
a5e5224
Updated settings permission denied response
we-alam-a001 Jan 8, 2024
6c6de55
Updated: permission denied response
we-alam-a001 Jan 8, 2024
233c580
Updated: theme controller
we-alam-a001 Jan 8, 2024
d3ea9f7
Updated: permission denied response
we-alam-a001 Jan 8, 2024
cc7d5a5
Merge remote-tracking branch 'origin/2.x-feature/permission-denied-re…
we-alam-a001 Jan 8, 2024
a62c2e8
Added: functions to get language string
we-alam-a001 Jan 8, 2024
020caf0
Added: run migrations and seeders after installed
we-alam-a001 Jan 9, 2024
eff4778
Updated: setup stores
we-alam-a001 Jan 9, 2024
005149d
Updated: run seeders method
we-alam-a001 Jan 9, 2024
c7b313b
Updated: run migrations and seeders after installed
we-alam-a001 Jan 9, 2024
bd05184
Updated: function in setup store
we-alam-a001 Jan 9, 2024
d87c98f
Added: run seeder functionality in localization
we-alam-a001 Jan 9, 2024
b872b31
Added: functions to get language string
we-alam-a001 Jan 9, 2024
94ad323
Merge remote-tracking branch 'origin/2.x-feature/generate-language-fi…
we-alam-a001 Jan 9, 2024
4330c01
Updated: naming of language strings
we-alam-a001 Jan 10, 2024
115e5d1
Updated: permission denied response
we-vikram-wri231 Jan 10, 2024
c455a89
Updated: naming convention
we-alam-a001 Jan 10, 2024
bf55e0e
Updated: permission denied response
we-alam-a001 Jan 10, 2024
2771bf9
Updated: registrations permission response
we-alam-a001 Jan 10, 2024
5e54350
Updated: users permission response
we-alam-a001 Jan 10, 2024
c667cb2
Updated: themes permission response
we-alam-a001 Jan 10, 2024
39bf5c8
Updated: taxonomy permission response
we-alam-a001 Jan 10, 2024
53723de
Updated: roles permission response
we-alam-a001 Jan 10, 2024
d261d53
Updated: permission denied response of permission
we-alam-a001 Jan 10, 2024
097e5d8
Updated: modules permission response
we-alam-a001 Jan 10, 2024
264972e
Updated: media permission response
we-alam-a001 Jan 10, 2024
84e35e5
Updated: settings permission response
we-alam-a001 Jan 10, 2024
fd92d31
Updated: permission response in backup and settings
we-alam-a001 Jan 11, 2024
0b10c6c
Updated: advanced permission response
we-alam-a001 Jan 11, 2024
945a0ef
Updated: if condition in users actions
we-alam-a001 Jan 11, 2024
4cd6c72
Updated: if condition in users form and view
we-alam-a001 Jan 11, 2024
d588432
Updated: users assets language string
we-alam-a001 Jan 12, 2024
2b70394
Updated: conditions for language string error
we-alam-a001 Jan 12, 2024
afe5d1a
Updated: label of extend
we-alam-a001 Jan 12, 2024
e045755
Updated: condition when no strings provided
we-alam-a001 Jan 12, 2024
3aed7ca
Added: watch for looking store assets loaded
we-alam-a001 Jan 12, 2024
d89128d
Updated: users title
we-alam-a001 Jan 12, 2024
ff41a29
Merge pull request #241 from webreinvent/2.x-feature/added-restricted…
themodernpk Jan 12, 2024
6cae5b9
Updated: dashboard language strings
we-alam-a001 Jan 12, 2024
eeac38b
Fixed: registration not found error message
we-alam-a001 Jan 12, 2024
d6024b6
Added: functions to get language string
we-alam-a001 Jan 8, 2024
6348105
Added: run migrations and seeders after installed
we-alam-a001 Jan 9, 2024
c95e0b6
Updated: setup stores
we-alam-a001 Jan 9, 2024
e3ad41e
Updated: run seeders method
we-alam-a001 Jan 9, 2024
aa5b7e0
Updated: run migrations and seeders after installed
we-alam-a001 Jan 9, 2024
deb8967
Updated: function in setup store
we-alam-a001 Jan 9, 2024
899c146
Added: run seeder functionality in localization
we-alam-a001 Jan 9, 2024
6048d65
Updated: naming of language strings
we-alam-a001 Jan 10, 2024
958d731
Updated: naming convention
we-alam-a001 Jan 10, 2024
d3c0c36
Updated: if condition in users actions
we-alam-a001 Jan 11, 2024
3ad9956
Updated: if condition in users form and view
we-alam-a001 Jan 11, 2024
afc636e
Updated: users assets language string
we-alam-a001 Jan 12, 2024
bdf640f
Updated: conditions for language string error
we-alam-a001 Jan 12, 2024
9ec4791
Updated: label of extend
we-alam-a001 Jan 12, 2024
a5c02fd
Updated: condition when no strings provided
we-alam-a001 Jan 12, 2024
5469172
Added: watch for looking store assets loaded
we-alam-a001 Jan 12, 2024
a3f672b
Updated: users title
we-alam-a001 Jan 12, 2024
1e10a0b
Fixed: registration not found error message
we-alam-a001 Jan 12, 2024
6f6239e
Merge remote-tracking branch 'origin/2.x-feature/generate-language-fi…
we-vikram-wri231 Jan 13, 2024
4ec900d
Updated: page title strings
we-alam-a001 Jan 13, 2024
de3402c
Merge remote-tracking branch 'origin/2.x-feature/generate-language-fi…
we-alam-a001 Jan 13, 2024
b8f764f
Updated: style overflow
we-vikram-wri231 Jan 13, 2024
25923d0
Merge pull request #244 from webreinvent/2.x-feature/fixx-notificatio…
themodernpk Jan 15, 2024
fd0fca6
Merge pull request #243 from webreinvent/2.x-feature/generate-languag…
themodernpk Jan 15, 2024
1882ae5
Updated: language string of label
we-alam-a001 Jan 4, 2024
bf5827e
Updated: sidebar menu label extend and dashboard
we-alam-a001 Jan 4, 2024
5a0c3ca
Added: conditional if for language string
we-alam-a001 Jan 4, 2024
7cc0aa9
Fixed: login error while language is fr
we-alam-a001 Jan 4, 2024
4ffe099
Updated: extend controller for label
we-alam-a001 Jan 4, 2024
a69b94d
Fixed: to show bold text
we-alam-a001 Jan 5, 2024
72ca26a
Updated: dashboard language string
we-alam-a001 Jan 5, 2024
cc44817
Removed: unused line
we-alam-a001 Jan 5, 2024
91b5abc
Updated: dashboard language strings
we-alam-a001 Jan 12, 2024
6f99b4b
Merge remote-tracking branch 'origin/2.x-feature/update-dashbaord-loc…
we-alam-a001 Jan 16, 2024
97a2151
Updated: language strings after rebase
we-alam-a001 Jan 16, 2024
8f903c9
Merge pull request #239 from webreinvent/2.x-feature/update-dashbaord…
themodernpk Jan 19, 2024
b10382d
Updated: setup configuration and account page
we-vikram-wri231 Dec 30, 2023
33ab1d8
Updated: env app name to session prefix and session cookie
we-vikram-wri231 Dec 30, 2023
764dc90
Updated: rebuild assets
we-vikram-wri231 Dec 30, 2023
3a8b164
Updated: validation and placeholder text
we-vikram-wri231 Jan 3, 2024
532d568
Updated: rebuild assets
we-vikram-wri231 Jan 3, 2024
c4800f2
Updated: setup configuration and account page
we-vikram-wri231 Dec 30, 2023
366956d
Updated: rebuild assets
we-vikram-wri231 Dec 30, 2023
10fb87c
Updated: validation and placeholder text
we-vikram-wri231 Jan 3, 2024
42ea23e
Updated: rebuild assets
we-vikram-wri231 Jan 3, 2024
35af503
Merge remote-tracking branch 'origin/2.x-feature/session-fixes' into …
we-vikram-wri231 Jan 19, 2024
e9dd125
Merge pull request #233 from webreinvent/2.x-feature/session-fixes
themodernpk Jan 19, 2024
d62c411
Updated: permission denied response
we-vikram-wri231 Jan 6, 2024
af70ec4
Updated: registrations permission denied response
we-alam-a001 Jan 6, 2024
5990e45
Updated: haspermission param
we-vikram-wri231 Jan 6, 2024
cd2e021
Updated: users permission denied response
we-alam-a001 Jan 6, 2024
5f29150
Updated: all haspermission param
we-alam-a001 Jan 6, 2024
d9ede0d
Updated: permission denied response in roles
we-alam-a001 Jan 6, 2024
d1807fb
Updated: permission denied response in permissions
we-alam-a001 Jan 6, 2024
c8ce3b0
Updated: permission denied response in modules
we-alam-a001 Jan 6, 2024
53c0ed5
Updated: media permission denied response
we-alam-a001 Jan 8, 2024
db1143a
Updated: taxonomies permission denied response
we-alam-a001 Jan 8, 2024
7a75fda
Updated: themes permission denied response
we-alam-a001 Jan 8, 2024
cf3fc2e
Updated: advanced permission denied response
we-alam-a001 Jan 8, 2024
9ca07d9
Updated settings permission denied response
we-alam-a001 Jan 8, 2024
039e95f
Updated: permission denied response
we-alam-a001 Jan 8, 2024
07fd740
Updated: theme controller
we-alam-a001 Jan 8, 2024
88a3304
Updated: permission denied response
we-vikram-wri231 Jan 10, 2024
abcad0f
Updated: permission denied response
we-alam-a001 Jan 10, 2024
62f8e84
Updated: registrations permission response
we-alam-a001 Jan 10, 2024
9444d8a
Updated: users permission response
we-alam-a001 Jan 10, 2024
ad8a72f
Updated: themes permission response
we-alam-a001 Jan 10, 2024
f7b8fa8
Updated: taxonomy permission response
we-alam-a001 Jan 10, 2024
ca53dac
Updated: roles permission response
we-alam-a001 Jan 10, 2024
2e0507f
Updated: permission denied response of permission
we-alam-a001 Jan 10, 2024
2787739
Updated: modules permission response
we-alam-a001 Jan 10, 2024
f419dde
Updated: media permission response
we-alam-a001 Jan 10, 2024
7127d79
Updated: settings permission response
we-alam-a001 Jan 10, 2024
c0674e8
Updated: permission response in backup and settings
we-alam-a001 Jan 11, 2024
daafd88
Updated: advanced permission response
we-alam-a001 Jan 11, 2024
6ce454e
Merge remote-tracking branch 'origin/2.x-feature/permission-denied-re…
we-vikram-wri231 Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Helpers/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,15 @@ function vh_get_backend_file($file_path)
return vh_get_backend_theme_url()."/".$file_path;
}
//-----------------------------------------------------------------------------------
function vh_get_permission_denied_response($permission_slugs){
$response['success'] = false;

$text = implode(', ',$permission_slugs);

$response['errors'][] = trans("vaahcms-general.permission_denied");
if(env('APP_DEBUG')){
$response['hint'][] = 'You don\'t have "'.$text.'" permission.';
}
return $response;
}
//-----------------------------------------------------------------------------------
14 changes: 6 additions & 8 deletions Http/Controllers/Backend/Advanced/BatchesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ public function __construct()
//----------------------------------------------------------
public function getAssets(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@we-vikram-wri231 writing has-access-of-advanced-section text multiple time, no point

$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-advanced-section';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@we-vikram-wri231 this should be array instead of line number 21, make this change everywhere else as well


return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -68,11 +67,10 @@ public function getAssets(Request $request): JsonResponse
//----------------------------------------------------------
public function getList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-batches-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-batches-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down
15 changes: 7 additions & 8 deletions Http/Controllers/Backend/Advanced/FailedJobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ public function __construct()
//----------------------------------------------------------
public function getAssets(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-advanced-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -68,12 +67,12 @@ public function getAssets(Request $request): JsonResponse
//----------------------------------------------------------
public function getList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-failed-jobs-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-failed-jobs-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
$response = FailedJob::getList($request);
} catch (\Exception $e) {
Expand Down
14 changes: 6 additions & 8 deletions Http/Controllers/Backend/Advanced/JobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ public function __construct()
//----------------------------------------------------------
public function getAssets(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-advanced-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -67,11 +66,10 @@ public function getAssets(Request $request): JsonResponse
//----------------------------------------------------------
public function getList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-jobs-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-jobs-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down
36 changes: 15 additions & 21 deletions Http/Controllers/Backend/Advanced/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ public function __construct()
//----------------------------------------------------------
public function getAssets(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-advanced-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -69,11 +68,10 @@ public function getAssets(Request $request): JsonResponse
//----------------------------------------------------------
public function getList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-logs-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-logs-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -164,11 +162,10 @@ public function getList(Request $request): JsonResponse
//----------------------------------------------------------
public function getItem(Request $request, $name): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-advanced-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -230,11 +227,10 @@ public function getItem(Request $request, $name): JsonResponse
//----------------------------------------------------------
public function downloadFile(Request $request, $file_name): BinaryFileResponse | string | JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-advanced-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -262,12 +258,10 @@ public function downloadFile(Request $request, $file_name): BinaryFileResponse |
//----------------------------------------------------------
public function postActions(Request $request, $action): JsonResponse
{
$permission_slug = 'has-access-of-advanced-section';

if (!Auth::user()->hasPermission('has-access-of-advanced-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down
77 changes: 33 additions & 44 deletions Http/Controllers/Backend/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ public function __construct()
//----------------------------------------------------------
public function getAssets(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-media-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-media-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down Expand Up @@ -83,11 +82,10 @@ public function getAssets(Request $request): JsonResponse
//----------------------------------------------------------
public function getList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('has-access-of-media-section')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'has-access-of-media-section';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand All @@ -109,11 +107,10 @@ public function getList(Request $request): JsonResponse
//----------------------------------------------------------
public function updateList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('can-update-media')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'can-update-media';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand All @@ -135,15 +132,14 @@ public function updateList(Request $request): JsonResponse
//----------------------------------------------------------
public function listAction(Request $request, $type): JsonResponse
{
if (!Auth::user()->hasPermission('can-update-media') ||
!Auth::user()->hasPermission('can-manage-media')
) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slugs = ['can-update-media','can-manage-media'];

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slugs[0]) ||
!Auth::user()->hasPermission($permission_slugs[1])) {
return response()->json(vh_get_permission_denied_response($permission_slugs));
}


try {
$response = Media::listAction($request, $type);
} catch (\Exception $e) {
Expand All @@ -163,11 +159,10 @@ public function listAction(Request $request, $type): JsonResponse
//----------------------------------------------------------
public function deleteList(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('can-delete-media')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'can-delete-media';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand All @@ -189,11 +184,10 @@ public function deleteList(Request $request): JsonResponse
//----------------------------------------------------------
public function getItem(Request $request, $id): JsonResponse
{
if (!Auth::user()->hasPermission('can-read-media')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'can-read-media';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand All @@ -215,11 +209,10 @@ public function getItem(Request $request, $id): JsonResponse
//----------------------------------------------------------
public function updateItem(Request $request, $id): JsonResponse
{
if (!Auth::user()->hasPermission('can-update-media')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'can-update-media';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand All @@ -241,11 +234,10 @@ public function updateItem(Request $request, $id): JsonResponse
//----------------------------------------------------------
public function deleteItem(Request $request, $id): JsonResponse
{
if (!Auth::user()->hasPermission('can-update-media')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'can-update-media';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand All @@ -267,13 +259,11 @@ public function deleteItem(Request $request, $id): JsonResponse
//----------------------------------------------------------
public function itemAction(Request $request, $id, $action): JsonResponse
{
if (!Auth::user()->hasPermission('can-update-media') ||
!Auth::user()->hasPermission('can-manage-media')
) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slugs = ['can-update-media','can-manage-media'];

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slugs[0]) ||
!Auth::user()->hasPermission($permission_slugs[1])) {
return response()->json(vh_get_permission_denied_response($permission_slugs));
}

try {
Expand Down Expand Up @@ -426,11 +416,10 @@ public function upload(Request $request): JsonResponse
//----------------------------------------------------------
public function postCreate(Request $request): JsonResponse
{
if (!Auth::user()->hasPermission('can-create-media')) {
$response['success'] = false;
$response['errors'][] = trans("vaahcms::messages.permission_denied");
$permission_slug = 'can-create-media';

return response()->json($response);
if(!Auth::user()->hasPermission($permission_slug)) {
return response()->json(vh_get_permission_denied_response([$permission_slug]));
}

try {
Expand Down
Loading