user()?->can('updates.manage') ?? false; } protected static ?string $slug = 'aktualisierung'; public string $licenseEmail = ''; public string $licenseKey = ''; public ?string $licenseError = null; public function mount(LicenseStore $license): void { $this->licenseEmail = (string) $license->email(); } public function saveLicense(LicenseStore $license, LicenseService $service): void { $this->validate([ 'licenseEmail' => ['required', 'email', 'max:255'], 'licenseKey' => [$license->hasLicense() ? 'nullable' : 'required', 'string', 'max:500'], ], attributes: ['licenseEmail' => 'Lizenz-E-Mail', 'licenseKey' => 'Lizenzschlüssel']); $license->setLicense($this->licenseEmail, filled($this->licenseKey) ? $this->licenseKey : (string) $license->key()); $this->licenseKey = ''; Audit::log('license.saved', ['email' => $this->licenseEmail]); $this->checkLicense($service); } public function checkLicense(LicenseService $service): void { $this->licenseError = null; try { $service->check(); Notification::make()->success()->title('Lizenz geprüft')->send(); } catch (ServerError $e) { $this->licenseError = ServerMessages::for($e); } catch (Throwable $e) { $this->licenseError = 'Die Lizenz konnte nicht geprüft werden: '.$e->getMessage(); } } public function releaseDevice(LicenseService $service, LicenseStore $license): void { try { $service->releaseDevice(); Audit::log('license.device_released', ['device_label' => $license->deviceLabel()]); Notification::make() ->success() ->title('Installation abgemeldet') ->body('Der Geräteplatz ist wieder frei. Updates sind erst nach erneuter Lizenzprüfung wieder möglich.') ->send(); } catch (ServerError $e) { Notification::make()->danger()->title('Abmelden fehlgeschlagen')->body(ServerMessages::for($e))->send(); } } /** * @return array */ protected function getViewData(): array { $version = app(InstalledVersion::class); $license = app(LicenseStore::class); $channels = app(Channels::class); try { $migrations = app(Migrations::class)->status(); } catch (Throwable) { $migrations = []; } return [ 'release' => $version->release(), 'shortSha' => $version->short(), 'channels' => $channels->all(), 'activeChannel' => $channels->active(), 'autoUpdate' => app(AutoUpdate::class)->enabled(), 'progress' => app(UpdateProgress::class)->get(), 'migrations' => $migrations, 'pendingMigrations' => count(array_filter($migrations, fn (array $m) => ! $m['ran'])), 'changelog' => app(Changelog::class)->sections(), 'hasLicense' => $license->hasLicense(), 'maskedKey' => ($key = $license->key()) ? str_repeat('•', 8).substr($key, -4) : null, 'licenseSummary' => app(LicenseService::class)->summary(), 'licenseStatusError' => ($code = $license->lastStatus()['error_code'] ?? null) ? ServerMessages::for(new ServerError($code, 0, $code)) : null, 'deviceLabel' => $license->deviceLabel(), ]; } }