Switch PHP views to Twig and add 2FA/UI enhancements
Migrate many view templates from raw PHP to Twig and modernize UI/UX for 2FA and settings. Controllers updated to provide avatar data and two-factor info (ProfileController, UserController) and SettingsController now includes timezone lists, notification preset selection, cron path, cached update state and rollback availability. ErrorHandler now attempts to render error pages via a new Core\TwigService with a safe fallback to raw PHP views. TwoFactorService generation silences deprecated warnings during QR code creation. Numerous .php view files were removed and replaced with .twig equivalents (2fa setup/verify/backup-codes and many auth, dashboard, domains, errors, layout, users, tags, tld-registry, etc.), and core/TwigService was added. These changes move the app toward a Twig-based templating system, improve 2FA flows, surface avatar images in lists/profiles, and make error rendering more robust.
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\User;
|
||||
use App\Models\SessionManager;
|
||||
use App\Models\RememberToken;
|
||||
use App\Services\Logger;
|
||||
use App\Services\TwoFactorService;
|
||||
use App\Helpers\AvatarHelper;
|
||||
|
||||
class ProfileController extends Controller
|
||||
@@ -71,10 +72,30 @@ class ProfileController extends Controller
|
||||
// Format sessions for display (adds deviceIcon, browserInfo, timeAgo, sessionAge)
|
||||
$formattedSessions = \App\Helpers\SessionHelper::formatForDisplay($sessions);
|
||||
|
||||
// Avatar data
|
||||
$avatar = AvatarHelper::getAvatar($user, 80);
|
||||
|
||||
// 2FA status
|
||||
$twoFactorService = new TwoFactorService();
|
||||
$twoFactorPolicy = $twoFactorService->getTwoFactorPolicy();
|
||||
|
||||
$backupCodes = !empty($user['two_factor_backup_codes'])
|
||||
? json_decode($user['two_factor_backup_codes'], true)
|
||||
: [];
|
||||
|
||||
$twoFactorStatus = [
|
||||
'enabled' => !empty($user['two_factor_enabled']),
|
||||
'setup_at' => $user['two_factor_setup_at'] ?? null,
|
||||
'backup_codes_count' => is_array($backupCodes) ? count($backupCodes) : 0,
|
||||
'required' => $twoFactorService->isTwoFactorRequired($userId),
|
||||
];
|
||||
|
||||
$this->view('profile/index', [
|
||||
'user' => $user,
|
||||
'sessions' => $formattedSessions,
|
||||
'userModel' => $this->userModel,
|
||||
'avatar' => $avatar,
|
||||
'twoFactorStatus' => $twoFactorStatus,
|
||||
'twoFactorPolicy' => $twoFactorPolicy,
|
||||
'title' => 'My Profile'
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user