Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/DomainsController.php
<?php | <?php | ||||
namespace App\Http\Controllers\API\V4; | namespace App\Http\Controllers\API\V4; | ||||
use App\Domain; | use App\Domain; | ||||
use App\Http\Controllers\RelationController; | use App\Http\Controllers\RelationController; | ||||
use App\Backends\LDAP; | |||||
use App\Rules\UserEmailDomain; | use App\Rules\UserEmailDomain; | ||||
use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
use Illuminate\Support\Facades\Validator; | use Illuminate\Support\Facades\Validator; | ||||
class DomainsController extends RelationController | class DomainsController extends RelationController | ||||
{ | { | ||||
/** @var string Resource localization label */ | /** @var string Resource localization label */ | ||||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | class DomainsController extends RelationController | ||||
} | } | ||||
/** | /** | ||||
* Execute (synchronously) specified step in a domain setup process. | * Execute (synchronously) specified step in a domain setup process. | ||||
* | * | ||||
* @param \App\Domain $domain Domain object | * @param \App\Domain $domain Domain object | ||||
* @param string $step Step identifier (as in self::statusInfo()) | * @param string $step Step identifier (as in self::statusInfo()) | ||||
* | * | ||||
* @return bool True if the execution succeeded, False otherwise | * @return bool|null True if the execution succeeded, False if not, Null when | ||||
* the job has been sent to the worker (result unknown) | |||||
*/ | */ | ||||
public static function execProcessStep(Domain $domain, string $step): bool | public static function execProcessStep(Domain $domain, string $step): ?bool | ||||
{ | { | ||||
try { | try { | ||||
switch ($step) { | switch ($step) { | ||||
case 'domain-ldap-ready': | case 'domain-ldap-ready': | ||||
// Domain not in LDAP, create it | // Use worker to do the job | ||||
if (!$domain->isLdapReady()) { | \App\Jobs\Domain\CreateJob::dispatch($domain->id); | ||||
LDAP::createDomain($domain); | return null; | ||||
$domain->status |= Domain::STATUS_LDAP_READY; | |||||
$domain->save(); | |||||
} | |||||
return $domain->isLdapReady(); | |||||
case 'domain-verified': | case 'domain-verified': | ||||
// Domain existence not verified | // Domain existence not verified | ||||
$domain->verify(); | $domain->verify(); | ||||
return $domain->isVerified(); | return $domain->isVerified(); | ||||
case 'domain-confirmed': | case 'domain-confirmed': | ||||
// Domain ownership confirmation | // Domain ownership confirmation | ||||
Show All 10 Lines |