Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | public function store(Request $request) | ||||
'message' => __('app.user-create-success'), | 'message' => __('app.user-create-success'), | ||||
]); | ]); | ||||
} | } | ||||
/** | /** | ||||
* Update user data. | * Update user data. | ||||
* | * | ||||
* @param \Illuminate\Http\Request $request The API request. | * @param \Illuminate\Http\Request $request The API request. | ||||
* @params string $id User identifier | * @param string $id User identifier | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse The response | * @return \Illuminate\Http\JsonResponse The response | ||||
*/ | */ | ||||
public function update(Request $request, $id) | public function update(Request $request, $id) | ||||
{ | { | ||||
$user = User::find($id); | $user = User::find($id); | ||||
if (empty($user)) { | if (empty($user)) { | ||||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | public static function execProcessStep(User $user, string $step): bool | ||||
$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 | // User not in LDAP, create it | ||||
$job = new \App\Jobs\UserCreate($user); | $job = new \App\Jobs\User\CreateJob($user->id); | ||||
$job->handle(); | $job->handle(); | ||||
$user->refresh(); | |||||
return $user->isLdapReady(); | return $user->isLdapReady(); | ||||
case 'user-imap-ready': | case 'user-imap-ready': | ||||
// User not in IMAP? Verify again | // User not in IMAP? Verify again | ||||
$job = new \App\Jobs\UserVerify($user); | $job = new \App\Jobs\User\VerifyJob($user->id); | ||||
$job->handle(); | $job->handle(); | ||||
$user->refresh(); | |||||
return $user->isImapReady(); | return $user->isImapReady(); | ||||
} | } | ||||
} catch (\Exception $e) { | } catch (\Exception $e) { | ||||
\Log::error($e); | \Log::error($e); | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
Show All 13 Lines | public static function validateEmail( | ||||
bool $is_alias = false | bool $is_alias = false | ||||
): ?string { | ): ?string { | ||||
$attribute = $is_alias ? 'alias' : 'email'; | $attribute = $is_alias ? 'alias' : 'email'; | ||||
if (strpos($email, '@') === false) { | if (strpos($email, '@') === false) { | ||||
return \trans('validation.entryinvalid', ['attribute' => $attribute]); | return \trans('validation.entryinvalid', ['attribute' => $attribute]); | ||||
} | } | ||||
list($login, $domain) = explode('@', $email); | list($login, $domain) = explode('@', Str::lower($email)); | ||||
if (strlen($login) === 0 || strlen($domain) === 0) { | if (strlen($login) === 0 || strlen($domain) === 0) { | ||||
return \trans('validation.entryinvalid', ['attribute' => $attribute]); | return \trans('validation.entryinvalid', ['attribute' => $attribute]); | ||||
} | } | ||||
// Check if domain exists | // Check if domain exists | ||||
$domain = Domain::where('namespace', Str::lower($domain))->first(); | $domain = Domain::where('namespace', $domain)->first(); | ||||
if (empty($domain)) { | if (empty($domain)) { | ||||
return \trans('validation.domaininvalid'); | return \trans('validation.domaininvalid'); | ||||
} | } | ||||
// Validate login part alone | // Validate login part alone | ||||
$v = Validator::make( | $v = Validator::make( | ||||
[$attribute => $login], | [$attribute => $login], | ||||
Show All 32 Lines |