Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/js/components/Clients.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<!-- Secret -->
<td style="vertical-align: middle;">
<code>{{ client.secret }}</code>
<code>{{ client.secret ? client.secret : '-' }}</code>
</td>

<!-- Edit Button -->
Expand Down Expand Up @@ -337,7 +337,7 @@

axios[method](uri, form)
.then(response => {
this.getClients();
this.clients.push(response.data);

form.name = '';
form.redirect = '';
Expand Down
21 changes: 17 additions & 4 deletions src/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Http\Response;
use Laravel\Passport\ClientRepository;
use Laravel\Passport\Http\Rules\RedirectRule;
use Laravel\Passport\Passport;

class ClientController
{
Expand Down Expand Up @@ -59,14 +60,20 @@ public function forUser(Request $request)
{
$userId = $request->user()->getAuthIdentifier();

return $this->clients->activeForUser($userId)->makeVisible('secret');
$clients = $this->clients->activeForUser($userId);

if (Passport::$hashesClientSecrets) {
return $clients;
}

return $clients->makeVisible('secret');
}

/**
* Store a new client.
*
* @param \Illuminate\Http\Request $request
* @return \Laravel\Passport\Client
* @return \Laravel\Passport\Client|array
*/
public function store(Request $request)
{
Expand All @@ -76,10 +83,16 @@ public function store(Request $request)
'confidential' => 'boolean',
])->validate();

return $this->clients->create(
$client = $this->clients->create(
$request->user()->getAuthIdentifier(), $request->name, $request->redirect,
false, false, (bool) $request->input('confidential', true)
)->makeVisible('secret');
);

if (Passport::$hashesClientSecrets) {
return ['secret' => $client->plainSecret] + $client->toArray();
}

return $client->makeVisible('secret');
}

/**
Expand Down