Skip to content

Commit 367dc44

Browse files
committed
Merge branch '9.x'
# Conflicts: # CHANGELOG.md
2 parents fedcf05 + a368f9e commit 367dc44

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Release Notes
22

3-
## [Unreleased](https://github.com/laravel/passport/compare/v9.0.0...master)
3+
## [Unreleased](https://github.com/laravel/passport/compare/v9.0.1...master)
4+
5+
6+
## [v9.0.1 (2020-05-06)](https://github.com/laravel/passport/compare/v9.0.0...v9.0.1)
7+
8+
### Fixed
9+
- Fix displaying secret in Vue component ([#1244](https://github.com/laravel/passport/pull/1244))
10+
- Moved provider check to bearer token only ([#1246](https://github.com/laravel/passport/pull/1246))
11+
- Fix create client call ([aff9d09](https://github.com/laravel/passport/commit/aff9d0933737354d04df98cfc431fa20309be03a))
412

513

614
## [v9.0.0 (2020-05-05)](https://github.com/laravel/passport/compare/v8.5.0...v9.0.0)

resources/js/components/Clients.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
<!-- Secret -->
5252
<td style="vertical-align: middle;">
53-
<code>{{ client.secret }}</code>
53+
<code>{{ client.secret ? client.secret : '-' }}</code>
5454
</td>
5555

5656
<!-- Edit Button -->
@@ -337,7 +337,7 @@
337337
338338
axios[method](uri, form)
339339
.then(response => {
340-
this.getClients();
340+
this.clients.push(response.data);
341341
342342
form.name = '';
343343
form.redirect = '';

src/Guards/TokenGuard.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ protected function hasValidProvider(Request $request)
108108
*/
109109
public function user(Request $request)
110110
{
111-
if (! $this->hasValidProvider($request)) {
112-
return;
113-
}
114-
115111
if ($request->bearerToken()) {
116112
return $this->authenticateViaBearerToken($request);
117113
} elseif ($request->cookie(Passport::cookie())) {
@@ -154,6 +150,10 @@ protected function authenticateViaBearerToken($request)
154150
return;
155151
}
156152

153+
if (! $this->hasValidProvider($request)) {
154+
return;
155+
}
156+
157157
// If the access token is valid we will retrieve the user according to the user ID
158158
// associated with the token. We will use the provider implementation which may
159159
// be used to retrieve users from Eloquent. Next, we'll be ready to continue.

src/Http/Controllers/ClientController.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Http\Response;
88
use Laravel\Passport\ClientRepository;
99
use Laravel\Passport\Http\Rules\RedirectRule;
10+
use Laravel\Passport\Passport;
1011

1112
class ClientController
1213
{
@@ -59,14 +60,20 @@ public function forUser(Request $request)
5960
{
6061
$userId = $request->user()->getAuthIdentifier();
6162

62-
return $this->clients->activeForUser($userId)->makeVisible('secret');
63+
$clients = $this->clients->activeForUser($userId);
64+
65+
if (Passport::$hashesClientSecrets) {
66+
return $clients;
67+
}
68+
69+
return $clients->makeVisible('secret');
6370
}
6471

6572
/**
6673
* Store a new client.
6774
*
6875
* @param \Illuminate\Http\Request $request
69-
* @return \Laravel\Passport\Client
76+
* @return \Laravel\Passport\Client|array
7077
*/
7178
public function store(Request $request)
7279
{
@@ -76,10 +83,16 @@ public function store(Request $request)
7683
'confidential' => 'boolean',
7784
])->validate();
7885

79-
return $this->clients->create(
86+
$client = $this->clients->create(
8087
$request->user()->getAuthIdentifier(), $request->name, $request->redirect,
81-
false, false, (bool) $request->input('confidential', true)
82-
)->makeVisible('secret');
88+
null, false, false, (bool) $request->input('confidential', true)
89+
);
90+
91+
if (Passport::$hashesClientSecrets) {
92+
return ['secret' => $client->plainSecret] + $client->toArray();
93+
}
94+
95+
return $client->makeVisible('secret');
8396
}
8497

8598
/**

tests/ClientControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function test_clients_can_be_stored()
4848

4949
$clients->shouldReceive('create')
5050
->once()
51-
->with(1, 'client name', 'http://localhost', false, false, true)
51+
->with(1, 'client name', 'http://localhost', null, false, false, true)
5252
->andReturn($client = new Client);
5353

5454
$redirectRule = m::mock(RedirectRule::class);
@@ -86,7 +86,7 @@ public function test_public_clients_can_be_stored()
8686

8787
$clients->shouldReceive('create')
8888
->once()
89-
->with(1, 'client name', 'http://localhost', false, false, false)
89+
->with(1, 'client name', 'http://localhost', null, false, false, false)
9090
->andReturn($client = new Client);
9191

9292
$redirectRule = m::mock(RedirectRule::class);

0 commit comments

Comments
 (0)