Some demo user protections

This commit is contained in:
Sander Dorigo
2026-03-24 10:35:35 +01:00
parent 9c1f79110c
commit 21c3dc3f56
+10 -5
View File
@@ -246,14 +246,13 @@ final class PreferencesController extends Controller
$all = $request->only($keys);
foreach (config('notifications.notifications.user') as $key => $info) {
$key = sprintf('notification_%s', $key);
if (array_key_exists($key, $all)) {
if (array_key_exists($key, $all) && false === auth()->user()->hasRole('demo')) {
Log::debug(sprintf('update notification to true: %s', $key));
Preferences::set($key, true);
continue;
}
if (!array_key_exists($key, $all)) {
Log::debug(sprintf('update notification to false: %s', $key));
Preferences::set($key, false);
}
Log::debug(sprintf('update notification to false: %s', $key));
Preferences::set($key, false);
}
unset($all);
@@ -369,6 +368,12 @@ final class PreferencesController extends Controller
$all = $request->only(['channel']);
$channel = $all['channel'] ?? '';
if (true === auth()->user()->hasRole('demo')) {
session()->flash('error', (string) trans('firefly.not_available_demo_user'));
return redirect(route('preferences.index'));
}
switch ($channel) {
default:
session()->flash('error', (string) trans('firefly.notification_test_failed', ['channel' => $channel]));