Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/User/CreateJob.php
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | |||||
return; | return; | ||||
} | } | ||||
if ($withLdap && !$domain->isLdapReady()) { | if ($withLdap && !$domain->isLdapReady()) { | ||||
$this->release(60); | $this->release(60); | ||||
return; | return; | ||||
} | } | ||||
if (!$user->isActive() && ($script = \config('services.abuse-check'))) { | |||||
exec($script . ' ' . $this->userId, $output, $retval); | |||||
// We expect error code 0, so an error in the script does not cause user suspension | |||||
// FIXME: Should an error stop the process of user creation or not? | |||||
if ($retval > 0) { | |||||
throw new \Exception("Abuse check failed for user {$this->userId}."); | |||||
} | |||||
// The script should output "ABUSE" if the user is a suspected spammer | |||||
if (strpos(implode('', $output), 'ABUSE') !== false) { | |||||
$user->status |= \App\User::STATUS_SUSPENDED; | |||||
} | |||||
} | |||||
$user->status |= \App\User::STATUS_ACTIVE; | |||||
$user->save(); | |||||
if ($withLdap && !$user->isLdapReady()) { | if ($withLdap && !$user->isLdapReady()) { | ||||
\App\Backends\LDAP::createUser($user); | \App\Backends\LDAP::createUser($user); | ||||
$user->status |= \App\User::STATUS_LDAP_READY; | $user->status |= \App\User::STATUS_LDAP_READY; | ||||
$user->save(); | $user->save(); | ||||
} | } | ||||
if (!$user->isImapReady()) { | if (!$user->isImapReady()) { | ||||
if (!\App\Backends\IMAP::createUser($user)) { | if (!\App\Backends\IMAP::createUser($user)) { | ||||
throw new \Exception("Failed to create mailbox for user {$this->userId}."); | throw new \Exception("Failed to create mailbox for user {$this->userId}."); | ||||
} | } | ||||
$user->status |= \App\User::STATUS_IMAP_READY; | $user->status |= \App\User::STATUS_IMAP_READY; | ||||
} | |||||
$user->status |= \App\User::STATUS_ACTIVE; | |||||
$user->save(); | $user->save(); | ||||
} | } | ||||
} | } | ||||
} |