handled some bugs and adde some feature for banner
This commit is contained in:
@@ -13,6 +13,16 @@ class SettingsController extends Controller
|
||||
|
||||
private const NEW_SETTING_NOTIFY_MOBILE = '09134469985';
|
||||
|
||||
/**
|
||||
* کلیدهایی که پنل ادمین باید بتواند ویرایش کند حتی اگر در DB هنوز can_edit=0 باشد
|
||||
* (بنرها / سایتهای ریگیری).
|
||||
*/
|
||||
private const PANEL_MANAGED_KEYS = [
|
||||
'tracking_systems',
|
||||
'tracking_systems_enabled',
|
||||
'banner_enabled',
|
||||
];
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Setting::query()
|
||||
@@ -56,7 +66,7 @@ class SettingsController extends Controller
|
||||
$setting = new Setting();
|
||||
$setting->key = $request->key;
|
||||
$setting->can_edit = $isSystemDeploy ? 0 : 1;
|
||||
} elseif (!$setting->can_edit && !$isDeployAdmin) {
|
||||
} elseif (!$setting->can_edit && !$isDeployAdmin && !$this->isPanelManagedKey((string) $request->key)) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
@@ -119,4 +129,9 @@ class SettingsController extends Controller
|
||||
|
||||
return $this->normalizeAdminMobile($user->mobile ?? '') === self::DEPLOY_ADMIN_MOBILE_SUFFIX;
|
||||
}
|
||||
|
||||
private function isPanelManagedKey(string $key): bool
|
||||
{
|
||||
return in_array($key, self::PANEL_MANAGED_KEYS, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user