Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | public static function statusInfo(User $user): array | ||||
} | } | ||||
// Check if the user is a controller of his wallet | // Check if the user is a controller of his wallet | ||||
$isController = $user->canDelete($user); | $isController = $user->canDelete($user); | ||||
$hasCustomDomain = $user->wallet()->entitlements() | $hasCustomDomain = $user->wallet()->entitlements() | ||||
->where('entitleable_type', Domain::class) | ->where('entitleable_type', Domain::class) | ||||
->count() > 0; | ->count() > 0; | ||||
// Get user's beta entitlements | |||||
$betaSKUs = $user->entitlements()->select('skus.title') | |||||
->join('skus', 'skus.id', '=', 'entitlements.sku_id') | |||||
->where('handler_class', 'like', 'App\\\\Handlers\\\\Beta\\\\%') | |||||
->get() | |||||
->pluck('title') | |||||
->unique() | |||||
->all(); | |||||
return [ | return [ | ||||
'betaSKUs' => $betaSKUs, | |||||
// TODO: This will change when we enable all users to create domains | // TODO: This will change when we enable all users to create domains | ||||
'enableDomains' => $isController && $hasCustomDomain, | 'enableDomains' => $isController && $hasCustomDomain, | ||||
'enableUsers' => $isController, | 'enableUsers' => $isController, | ||||
'enableWallets' => $isController, | 'enableWallets' => $isController, | ||||
'process' => $process, | 'process' => $process, | ||||
'processState' => $state, | 'processState' => $state, | ||||
'isReady' => $all === $checked, | 'isReady' => $all === $checked, | ||||
]; | ]; | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | public function update(Request $request, $id) | ||||
} | } | ||||
// TODO: Make sure that UserUpdate job is created in case of entitlements update | // TODO: Make sure that UserUpdate job is created in case of entitlements update | ||||
// and no password change. So, for example quota change is applied to LDAP | // and no password change. So, for example quota change is applied to LDAP | ||||
// TODO: Review use of $user->save() in the above context | // TODO: Review use of $user->save() in the above context | ||||
DB::commit(); | DB::commit(); | ||||
return response()->json([ | $response = [ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'message' => __('app.user-update-success'), | 'message' => __('app.user-update-success'), | ||||
]); | ]; | ||||
// For self-update refresh the statusInfo in the UI | |||||
if ($user->id == $current_user->id) { | |||||
$response['statusInfo'] = self::statusInfo($user); | |||||
} | |||||
return response()->json($response); | |||||
} | } | ||||
/** | /** | ||||
* Get the guard to be used during authentication. | * Get the guard to be used during authentication. | ||||
* | * | ||||
* @return \Illuminate\Contracts\Auth\Guard | * @return \Illuminate\Contracts\Auth\Guard | ||||
*/ | */ | ||||
public function guard() | public function guard() | ||||
▲ Show 20 Lines • Show All 329 Lines • Show Last 20 Lines |