Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | public static function statusInfo(User $user): array | ||||
$state = $all === $checked ? 'done' : 'running'; | $state = $all === $checked ? 'done' : 'running'; | ||||
// After 180 seconds assume the process is in failed state, | // After 180 seconds assume the process is in failed state, | ||||
// this should unlock the Refresh button in the UI | // this should unlock the Refresh button in the UI | ||||
if ($all !== $checked && $user->created_at->diffInSeconds(Carbon::now()) > 180) { | if ($all !== $checked && $user->created_at->diffInSeconds(Carbon::now()) > 180) { | ||||
$state = 'failed'; | $state = 'failed'; | ||||
} | } | ||||
// Check if the user is a controller of his wallet | |||||
$isController = $user->canDelete($user); | |||||
$hasCustomDomain = $user->wallet()->entitlements() | |||||
->where('entitleable_type', Domain::class) | |||||
->count() > 0; | |||||
return [ | return [ | ||||
// TODO: This will change when we enable all users to create domains | |||||
'enableDomains' => $isController && $hasCustomDomain, | |||||
'enableUsers' => $isController, | |||||
'enableWallets' => $isController, | |||||
'process' => $process, | 'process' => $process, | ||||
'processState' => $state, | 'processState' => $state, | ||||
'isReady' => $all === $checked, | 'isReady' => $all === $checked, | ||||
]; | ]; | ||||
} | } | ||||
/** | /** | ||||
* Create a new user record. | * Create a new user record. | ||||
▲ Show 20 Lines • Show All 444 Lines • Show Last 20 Lines |