Add demo mode restrictions to user operations.
Added functionalities to restrict certain user operations like update, password change, and deletion in demo mode. This is done to prevent demo users from modifying crucial data. Helper methods are created for standard re-usable checks. Also, Blade directive is added for frontend UI demo checks.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -21,4 +22,18 @@ final readonly class Helpers
|
||||
public static function getUserTimeZone() {
|
||||
return auth()->user()?->timezone ?? config('app.user_timezone');
|
||||
}
|
||||
|
||||
public static function isDemoMode(): bool
|
||||
{
|
||||
return config('app.demo_mode', false);
|
||||
}
|
||||
|
||||
public static function isDemoModeAndUserDenyUpdate(User $user): bool
|
||||
{
|
||||
if (self::isDemoMode() !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->email === config('app.demo_email');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user