mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
This commit is contained in:
parent
4f251bf37e
commit
42b515e322
21 changed files with 2212 additions and 32 deletions
|
|
@ -9,9 +9,6 @@ use App\Models\Plugin;
|
|||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
class MashupCreateCommand extends Command
|
||||
{
|
||||
/**
|
||||
|
|
@ -88,9 +85,9 @@ class MashupCreateCommand extends Command
|
|||
return null;
|
||||
}
|
||||
|
||||
$deviceId = select(
|
||||
label: 'Select a device',
|
||||
options: $devices->mapWithKeys(fn ($device) => [$device->id => $device->name])->toArray()
|
||||
$deviceId = $this->choice(
|
||||
'Select a device',
|
||||
$devices->mapWithKeys(fn ($device) => [$device->id => $device->name])->toArray()
|
||||
);
|
||||
|
||||
return $devices->firstWhere('id', $deviceId);
|
||||
|
|
@ -106,9 +103,9 @@ class MashupCreateCommand extends Command
|
|||
return null;
|
||||
}
|
||||
|
||||
$playlistId = select(
|
||||
label: 'Select a playlist',
|
||||
options: $playlists->mapWithKeys(fn (Playlist $playlist) => [$playlist->id => $playlist->name])->toArray()
|
||||
$playlistId = $this->choice(
|
||||
'Select a playlist',
|
||||
$playlists->mapWithKeys(fn (Playlist $playlist) => [$playlist->id => $playlist->name])->toArray()
|
||||
);
|
||||
|
||||
return $playlists->firstWhere('id', $playlistId);
|
||||
|
|
@ -116,24 +113,29 @@ class MashupCreateCommand extends Command
|
|||
|
||||
protected function selectLayout(): ?string
|
||||
{
|
||||
return select(
|
||||
label: 'Select a layout',
|
||||
options: PlaylistItem::getAvailableLayouts()
|
||||
return $this->choice(
|
||||
'Select a layout',
|
||||
PlaylistItem::getAvailableLayouts()
|
||||
);
|
||||
}
|
||||
|
||||
protected function getMashupName(): ?string
|
||||
{
|
||||
return text(
|
||||
label: 'Enter a name for this mashup',
|
||||
required: true,
|
||||
default: 'Mashup',
|
||||
validate: fn (string $value) => match (true) {
|
||||
mb_strlen($value) < 1 => 'The name must be at least 2 characters.',
|
||||
mb_strlen($value) > 50 => 'The name must not exceed 50 characters.',
|
||||
default => null,
|
||||
}
|
||||
);
|
||||
$name = $this->ask('Enter a name for this mashup', 'Mashup');
|
||||
|
||||
if (mb_strlen($name) < 2) {
|
||||
$this->error('The name must be at least 2 characters.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mb_strlen($name) > 50) {
|
||||
$this->error('The name must not exceed 50 characters.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
protected function selectPlugins(string $layout): Collection
|
||||
|
|
@ -159,9 +161,9 @@ class MashupCreateCommand extends Command
|
|||
default => ($i + 1).'th'
|
||||
};
|
||||
|
||||
$pluginId = select(
|
||||
label: "Select the $position plugin",
|
||||
options: $availablePlugins
|
||||
$pluginId = $this->choice(
|
||||
"Select the $position plugin",
|
||||
$availablePlugins
|
||||
);
|
||||
|
||||
$selectedPlugins->push($plugins->firstWhere('id', $pluginId));
|
||||
|
|
|
|||
|
|
@ -40,13 +40,18 @@ class OidcTestCommand extends Command
|
|||
$clientId = config('services.oidc.client_id');
|
||||
$clientSecret = config('services.oidc.client_secret');
|
||||
$redirect = config('services.oidc.redirect');
|
||||
if (! $redirect) {
|
||||
$redirect = config('app.url', 'http://localhost').'/auth/oidc/callback';
|
||||
}
|
||||
$scopes = config('services.oidc.scopes', []);
|
||||
$defaultScopes = ['openid', 'profile', 'email'];
|
||||
$effectiveScopes = empty($scopes) ? $defaultScopes : $scopes;
|
||||
|
||||
$this->line('OIDC Endpoint: '.($endpoint ? "✅ {$endpoint}" : '❌ Not set'));
|
||||
$this->line('Client ID: '.($clientId ? "✅ {$clientId}" : '❌ Not set'));
|
||||
$this->line('Client Secret: '.($clientSecret ? '✅ Set' : '❌ Not set'));
|
||||
$this->line('Redirect URL: '.($redirect ? "✅ {$redirect}" : '❌ Not set'));
|
||||
$this->line('Scopes: '.(empty($scopes) ? '❌ Not set' : '✅ '.implode(', ', $scopes)));
|
||||
$this->line('Scopes: ✅ '.implode(', ', $effectiveScopes));
|
||||
|
||||
$this->newLine();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,16 +33,25 @@ class FirmwareDownloadJob implements ShouldQueue
|
|||
|
||||
try {
|
||||
$filename = "FW{$this->firmware->version_tag}.bin";
|
||||
Http::sink(storage_path("app/public/firmwares/$filename"))
|
||||
->get($this->firmware->url);
|
||||
$response = Http::get($this->firmware->url);
|
||||
|
||||
if (! $response->successful()) {
|
||||
throw new Exception('HTTP request failed with status: '.$response->status());
|
||||
}
|
||||
|
||||
// Save the response content to file
|
||||
Storage::disk('public')->put("firmwares/$filename", $response->body());
|
||||
|
||||
// Only update storage location if download was successful
|
||||
$this->firmware->update([
|
||||
'storage_location' => "firmwares/$filename",
|
||||
]);
|
||||
} catch (ConnectionException $e) {
|
||||
Log::error('Firmware download failed: '.$e->getMessage());
|
||||
// Don't update storage_location on failure
|
||||
} catch (Exception $e) {
|
||||
Log::error('An unexpected error occurred: '.$e->getMessage());
|
||||
// Don't update storage_location on failure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class OidcProvider extends AbstractProvider implements ProviderInterface
|
|||
{
|
||||
try {
|
||||
$url = $this->baseUrl.'/.well-known/openid-configuration';
|
||||
$client = new Client();
|
||||
$client = app(Client::class);
|
||||
$response = $client->get($url);
|
||||
$this->oidcConfig = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ class OidcProvider extends AbstractProvider implements ProviderInterface
|
|||
/**
|
||||
* Map the raw user array to a Socialite User instance.
|
||||
*/
|
||||
protected function mapUserToObject(array $user)
|
||||
public function mapUserToObject(array $user)
|
||||
{
|
||||
return (new User)->setRaw($user)->map([
|
||||
'id' => $user['sub'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue