| File was renamed from inc/managers/LoginManager.php |
| | |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\forms\TaxonomySelector; |
| | | use JVBase\meta\Form; |
| | | use JVBase\Instance;use JVBase\integrations\services\Cloudflare;use JVBase\meta\Form; |
| | | |
| | | use JVBase\registrar\Registrar;use WP_Error; |
| | | use JVBase\registrar\Registrar;use JVBase\rest\routes\LoginRoutes;use WP_Error; |
| | | use WP_User; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | | |
| | | class LoginManager |
| | | class Login |
| | | { |
| | | use Instance; |
| | | |
| | | protected ?Form $form = null; |
| | | protected Cache $cache; |
| | | |
| | |
| | | protected array $fields = []; |
| | | protected ?string $action = null; |
| | | protected string $title = ''; |
| | | protected static LoginManager $instance; |
| | | |
| | | // Token handlers registry |
| | | protected array $messageHandlers = []; |
| | |
| | | ]; |
| | | private int $max_file_size = 5242880; // 5MB in bytes |
| | | |
| | | private LoginRoutes $routes; |
| | | |
| | | public function __construct() |
| | | protected function __construct() |
| | | { |
| | | self::$instance = $this; |
| | | $this->cache = Cache::for('login'); |
| | | $this->cache->flush(); |
| | | $this->routes = new LoginRoutes(); |
| | | // $this->cache = Cache::for('login'); |
| | | // $this->cache->flush(); |
| | | // Initialize magic link support if enabled |
| | | if (Site::has('magic_link')) { |
| | | $this->initMagicLinkSupport(); |
| | |
| | | add_action('user_register', [$this, 'saveRegistrationFields'], 50, 2); |
| | | add_filter('the_seo_framework_sitemap_exclude_ids', [$this, 'excludeLoginSitemap'], 8, 1); |
| | | } |
| | | public static function getInstance():self |
| | | { |
| | | return self::$instance; |
| | | } |
| | | |
| | | public function excludeLoginSitemap(array $ids): array |
| | | { |
| | |
| | | exit; |
| | | } |
| | | $this->setup(); |
| | | $page = $this->cache->remember( |
| | | $this->getAction(), |
| | | function() { |
| | | return $this->renderPage(); |
| | | }, |
| | | 5 |
| | | ); |
| | | |
| | | echo $page; |
| | | echo $this->renderPage(); |
| | | return ''; |
| | | } |
| | | protected function renderPage() { |
| | |
| | | if (!Site::hasIntegration('cloudflare')) { |
| | | return; |
| | | } |
| | | JVB()->connect('cloudflare')->enqueueTurnstileScripts(); |
| | | Cloudflare::getInstance()->enqueueTurnstileScripts(); |
| | | } |
| | | |
| | | protected function verifyTurnstile(): bool |
| | | { |
| | | if (!Site::hasIntegration('cloudflare')) { |
| | | if (!Site::hasIntegration('cloudflare') || Cloudflare::getInstance()->isSetUp()) { |
| | | return true; // Not enabled, pass verification |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | return JVB()->connect('cloudflare')->verifyTurnstile($token); |
| | | return Cloudflare::getInstance()->verifyTurnstile($token); |
| | | } |
| | | |
| | | /************************************************************************ |
| | |
| | | |
| | | protected function maybeMagicLink(): void |
| | | { |
| | | if (!JVB()->magicLink() || !in_array($this->action, ['login', 'lostpassword'])) { |
| | | if (!MagicLinks::getInstance() || !in_array($this->action, ['login', 'lostpassword'])) { |
| | | return; |
| | | } |
| | | ?> |
| | |
| | | } |
| | | } |
| | | |
| | | // Initialize the login manager |
| | | new LoginManager(); |