+
+ public static function twoFactorCheck($uid, App $a)
+ {
+ // Check user setting, if 2FA disabled return
+ if (!PConfig::get($uid, '2fa', 'verified')) {
+ return;
+ }
+
+ // Check current path, if 2fa authentication module return
+ if ($a->argc > 0 && in_array($a->argv[0], ['ping', '2fa', 'view', 'help', 'api', 'proxy', 'logout'])) {
+ return;
+ }
+
+ // Case 1: 2FA session present and valid: return
+ if (Session::get('2fa')) {
+ return;
+ }
+
+ // Case 2: No valid 2FA session: redirect to code verification page
+ $a->internalRedirect('2fa');
+ }