Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 526 Lines • ▼ Show 20 Lines | public static function execProcessStep(User $user, string $step): ?bool | ||||
list ($local, $domain) = explode('@', $user->email); | list ($local, $domain) = explode('@', $user->email); | ||||
$domain = Domain::where('namespace', $domain)->first(); | $domain = Domain::where('namespace', $domain)->first(); | ||||
return DomainsController::execProcessStep($domain, $step); | return DomainsController::execProcessStep($domain, $step); | ||||
} | } | ||||
switch ($step) { | switch ($step) { | ||||
case 'user-ldap-ready': | case 'user-ldap-ready': | ||||
// User not in LDAP, create it | |||||
$job = new \App\Jobs\User\CreateJob($user->id); | |||||
$job->handle(); | |||||
$user->refresh(); | |||||
return $user->isLdapReady(); | |||||
case 'user-imap-ready': | case 'user-imap-ready': | ||||
// User not in IMAP? Verify again | // Use worker to do the job, frontend might not have the IMAP admin credentials | ||||
// Do it synchronously if the imap admin credentials are available | \App\Jobs\User\CreateJob::dispatch($user->id); | ||||
// otherwise let the worker do the job | |||||
if (!\config('imap.admin_password')) { | |||||
\App\Jobs\User\VerifyJob::dispatch($user->id); | |||||
return null; | return null; | ||||
} | } | ||||
$job = new \App\Jobs\User\VerifyJob($user->id); | |||||
$job->handle(); | |||||
$user->refresh(); | |||||
return $user->isImapReady(); | |||||
} | |||||
} catch (\Exception $e) { | } catch (\Exception $e) { | ||||
\Log::error($e); | \Log::error($e); | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |