code = strtoupper(trim($code)); $this->device = DeviceCode::where('code', $this->code)->first(); // Unknown or expired codes never render a grant button. $this->failed = $this->device === null || $this->device->expires_at->isPast(); } public function grant(): void { if ($this->failed || $this->device === null) { return; } $user = auth()->user(); if ($this->device->user_id !== null) { $this->failed = true; return; } // Mint a CLI token with abilities for the catalog (live now) and // submissions (endpoint to come; ability is forward-compatible). $token = $user->createToken('festbench-cli', ['gpus:read', 'results:submit'], now()->addYear()); $this->device->forceFill([ 'user_id' => $user->id, 'personal_access_token_id' => $token->accessToken->id, ])->save(); $this->granted = true; Flux::toast(variant: 'success', text: __('CLI connected. Return to your terminal.')); } }; ?>
@if ($granted) {{ __('CLI connected') }} {{ __('The festbench CLI on your machine now has access. Return to your terminal to continue.') }} @elseif ($failed) {{ __('Invalid or expired code') }} {{ __('This code does not exist or has expired. Re-run festbench login to get a fresh one.') }} {{ __('Back') }} @else {{ __('Confirm CLI access') }} {{ __('A festbench CLI is requesting access to your account. Make sure the code below matches the one shown in your terminal.') }}
{{ $code }}
{{ __('Grant access') }} @endif