Skip to content

Commit

Permalink
Set default Authentication Name
Browse files Browse the repository at this point in the history
  • Loading branch information
SupianIDz committed Apr 8, 2023
1 parent ad833e0 commit 28cdba8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/Commands/CreateAuthCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CreateAuthCommand extends Command
public function handle(Config $config) : void
{
if (! $this->argument('name')) {
$this->input->setArgument('name', $this->ask('ENTER NAME'));
$this->input->setArgument('name', 'default');
}

foreach (['auth', 'host'] as $option) {
Expand Down
12 changes: 3 additions & 9 deletions app/Commands/ListAlbumsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

namespace App\Commands;

use App\Config\Config;
use App\Exceptions\InvalidTokenException;
use App\GPhoto;
use App\Listeners\TokenListener;
use Exception;
use Google\ApiCore\ApiException;
use Google\ApiCore\ValidationException;
use Google\Photos\Types\Album;
use Illuminate\Support\Facades\Process;
use JetBrains\PhpStorm\NoReturn;
use LaravelZero\Framework\Commands\Command;
use Symfony\Component\Console\Input\InputOption;

Expand All @@ -38,12 +33,11 @@ class ListAlbumsCommand extends Command
*/
public function handle() : void
{
$auth = $this->option('auth');
if (! $auth) {
$auth = 'default';
if (! $this->option('auth')) {
$this->input->setOption('auth', 'default');
}

$gphoto = new GPhoto($auth);
$gphoto = new GPhoto($this->option('auth'));

$response = $gphoto->client()->listAlbums([
'excludeNonAppCreatedData' => true,
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/ReloadAuthCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ReloadAuthCommand extends Command
public function handle() : void
{
if (! $this->argument('name')) {
$this->input->setArgument('name', $this->ask('ENTER NAME'));
$this->input->setArgument('name', 'default');
}

$gphoto = new GPhoto($this->argument('name'));
Expand Down
6 changes: 5 additions & 1 deletion app/Commands/UploadAlbumCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ class UploadAlbumCommand extends Command
*/
public function handle() : void
{
if (! $this->option('auth')) {
$this->input->setOption('auth', 'default');
}

$gphoto = new GPhoto($this->option('auth'));

if (! file_exists($gphoto->path('config.json'))) {
$this->components->warn(
'CONFIG NOT EXISTS run "gphoto token:create" instead'
'CONFIG NOT EXISTS run "gphoto auth:create" instead'
);

return;
Expand Down
6 changes: 5 additions & 1 deletion app/Commands/UploadPhotoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ class UploadPhotoCommand extends Command
*/
public function handle() : void
{
if (! $this->option('auth')) {
$this->input->setOption('auth', 'default');
}

$gphoto = new GPhoto($this->option('auth'));

if (! file_exists($gphoto->path('storage/token'))) {
$this->components->error(
'TOKEN NOT EXISTS run "gphoto token:create" instead'
'TOKEN NOT EXISTS run "gphoto auth:create" instead'
);

return;
Expand Down

0 comments on commit 28cdba8

Please sign in to comment.