| | |
| | | |
| | | use JetBrains\PhpStorm\NoReturn; |
| | | use JVBase\base\Site; |
| | | use JVBase\inc\managers\ErrorHelper; |
| | | use JVBase\Instance; |
| | | use JVBase\integrations\services\Cloudflare; |
| | | use JVBase\meta\Form; |
| | |
| | | */ |
| | | class MagicLinks |
| | | { |
| | | use Instance; |
| | | use Instance, ErrorHelper; |
| | | protected Cache $cache; |
| | | protected Cache $referral_cache; |
| | | protected Cache $rateLimitCache; |
| | |
| | | #[NoReturn] protected function processSignup(array $token_data): void |
| | | { |
| | | if (!array_key_exists('email', $token_data) || !array_key_exists('name', $token_data)) { |
| | | Errors::getInstance()->log('MagicLinkManager', 'Could not process Signup'); |
| | | $this->logError('Could not process signup', 'processSignup', ['token_data' => $token_data]); |
| | | |
| | | $this->cleanURL(); |
| | | } |
| | | $user_id = wp_create_user( |
| | |
| | | protected function processReferralSignup(array $token_data): void |
| | | { |
| | | if (!array_key_exists('email', $token_data) || !array_key_exists('name', $token_data)) { |
| | | Errors::getInstance()->log('[MagicLinkManager]Could not process Referral Signup'); |
| | | $this->logError('Could not process referral signup', 'processReferralSignup', ['token_data' => $token_data]); |
| | | return; |
| | | } |
| | | |
| | |
| | | exit; |
| | | } |
| | | } else { |
| | | Errors::getInstance()->log( |
| | | '[MagicLinkManager]', |
| | | $user_id->get_error_message(), |
| | | $token_data |
| | | ); |
| | | $this->logError($user_id->get_error_message(), 'processReferralSignup'); |
| | | |
| | | $this->cleanURL(); |
| | | } |
| | | } |
| | |
| | | $user = get_user_by('ID', $token_data['user_id']); |
| | | |
| | | if (!$user) { |
| | | Errors::getInstance()->log( |
| | | 'MagicLinkManager', |
| | | 'Invalid user, could not reset password', |
| | | ); |
| | | $this->logError('Invalid user - could not reset password', 'processPasswordReset', ['token_data' => $token_data]); |
| | | $this->cleanURL(); |
| | | } |
| | | |