| @@ -88,23 +88,38 @@ | ||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | public function onAcymBeforeUserCreate(&$user) |
| 91 | 91 | { |
| 92 | + // CTE isn't installed | |
| 92 | 93 | if (!acym_isAcyCheckerInstalled()) return true; |
| 93 | 94 | |
| 95 | + // The email verification is disabled in the configuration | |
| 94 | 96 | if ($this->config->get('email_verification') == 0) return true; |
| 95 | 97 | |
| 96 | 98 | $this->loadAcychecker(); |
| 97 | 99 | |
| 98 | - $cteConfig = new ConfigurationClass(); | |
| 100 | + $cteConfig = ConfigurationClass::getConfiguration(); | |
| 99 | 101 | $conditions = $cteConfig->get('registration_conditions'); |
| 100 | 102 | |
| 103 | + // If no condition is selected, return | |
| 101 | 104 | if (empty($conditions) || $conditions === 'domain_not_exists') return true; |
| 102 | 105 | |
| 106 | + // Perform test using CTE code API | |
| 103 | 107 | $apiService = new ApiService(); |
| 104 | - $emailOk = $apiService->testEmail($user->email, $conditions); | |
| 108 | + | |
| 109 | + // Retro compatibility for AcyChecker 1.4 | |
| 110 | + if (method_exists($apiService, 'testUser')) { | |
| 111 | + $testUser = new stdClass(); | |
| 112 | + $testUser->email = $user->email; | |
| 113 | + $testUser->name = $user->name; | |
| 114 | + $emailOk = $apiService->testUser($testUser, $conditions); | |
| 115 | + } else { | |
| 116 | + $emailOk = $apiService->testEmail($user->email, $conditions); | |
| 117 | + } | |
| 118 | + | |
| 105 | 119 | if ($emailOk !== true) { |
| 106 | - acym_setVar('acychecker_error', acym_translation('ACYM_INVALID_EMAIL_ADDRESS')); | |
| 120 | + $message = $emailOk === 'blacklisted_name' ? 'ACYM_INVALID_NAME' : 'ACYM_INVALID_EMAIL_ADDRESS'; | |
| 121 | + acym_setVar('acychecker_error', acym_translation($message)); | |
| 107 | 122 | |
| 108 | 123 | return false; |
| 109 | 124 | } |
| 110 | 125 | |