hasher = $hasher; $this->repository = $repository; $this->revocationService = $revocationService; } /** * Update the user model instance. If the user has been removed as an administrator * revoke all of the authentication tokens that have beenn assigned to their account. * * @param \Pterodactyl\Models\User $user * @param array $data * @return \Illuminate\Support\Collection * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function handle(User $user, array $data): Collection { if (array_has($data, 'password')) { $data['password'] = $this->hasher->make($data['password']); } if ($this->isUserLevel(User::USER_LEVEL_ADMIN)) { if (array_get($data, 'root_admin', 0) == 0 && $user->root_admin) { $this->revocationService->handle($user, array_get($data, 'ignore_connection_error', false)); } } else { unset($data['root_admin']); } return collect([ 'model' => $this->repository->update($user->id, $data), 'exceptions' => $this->revocationService->getExceptions(), ]); } }