Skip to content

Commit ff699e9

Browse files
committed
Optimize
1 parent 0ade9e2 commit ff699e9

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

app/Commands/CreateAuthCommand.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ public function handle(Config $config) : void
5555

5656
$gphoto = new GPhoto($this->argument('name'));
5757

58+
$url = $gphoto->oauth()->buildFullAuthorizationUri([
59+
'access_type' => 'offline',
60+
]);
61+
62+
$this->components->info('Auth URL : ' . $url);
63+
5864
// open auth url in browser
5965
foreach (['xdg-open', 'sensible-browser', 'start'] as $command) {
60-
$process = Process::run(sprintf('%s "%s"', $command, $gphoto->oauth()->buildFullAuthorizationUri([
61-
'access_type' => 'offline',
62-
])));
66+
$process = Process::run(sprintf('%s "%s"', $command, $url));
6367

6468
if ($process->successful()) {
6569
break;
6670
}
6771
}
6872

6973
$listener = new TokenListener($gphoto);
70-
$listener->listen(
71-
$this->components
72-
);
74+
$listener->listen($this->components);
7375
}
7476

7577
/**

app/Commands/ReloadAuthCommand.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,23 @@ public function handle() : void
4747
return;
4848
}
4949

50+
$url = $gphoto->oauth()->buildFullAuthorizationUri([
51+
'access_type' => 'offline',
52+
]);
53+
54+
$this->components->info('Auth URL : ' . $url);
55+
5056
// open auth url in browser
5157
foreach (['xdg-open', 'sensible-browser', 'start'] as $command) {
52-
$process = Process::run(sprintf('%s "%s"', $command, $gphoto->oauth()->buildFullAuthorizationUri([
53-
'access_type' => 'offline',
54-
])));
58+
$process = Process::run(sprintf('%s "%s"', $command, $url));
5559

5660
if ($process->successful()) {
5761
break;
5862
}
5963
}
6064

6165
$listener = new TokenListener($gphoto);
62-
$listener->listen(
63-
$this->components
64-
);
66+
$listener->listen($this->components);
6567
}
6668

6769
/**

0 commit comments

Comments
 (0)