Skip to content

Commit 9d4aed7

Browse files
committed
Merge branch '10.x'
# Conflicts: # CHANGELOG.md
2 parents 7a026ac + c889d9c commit 9d4aed7

File tree

8 files changed

+34
-12
lines changed

8 files changed

+34
-12
lines changed

CHANGELOG.md

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

3-
## [Unreleased](https://github.com/laravel/passport/compare/v10.1.3...master)
3+
## [Unreleased](https://github.com/laravel/passport/compare/v10.1.4...master)
4+
5+
6+
## [v10.1.4 (2021-10-19)](https://github.com/laravel/passport/compare/v10.1.3...v10.1.4)
7+
8+
### Fixed
9+
- Ensure client model factory always creates models with a primary key ([#1492](https://github.com/laravel/passport/pull/1492)
410

511

612
## [v10.1.3 (2021-04-06)](https://github.com/laravel/passport/compare/v10.1.2...v10.1.3)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Laravel Passport is an OAuth2 server and API authentication package that is simp
1313

1414
## Official Documentation
1515

16-
Documentation for Passport can be found on the [Laravel website](https://laravel.com/docs/master/passport).
16+
Documentation for Passport can be found on the [Laravel website](https://laravel.com/docs/passport).
1717

1818
## Contributing
1919

art/logo.svg

Lines changed: 1 addition & 3 deletions
Loading

database/factories/ClientFactory.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Factories\Factory;
66
use Illuminate\Support\Str;
77
use Laravel\Passport\Client;
8+
use Laravel\Passport\Passport;
89

910
class ClientFactory extends Factory
1011
{
@@ -22,15 +23,32 @@ class ClientFactory extends Factory
2223
*/
2324
public function definition()
2425
{
25-
return [
26+
return $this->ensurePrimaryKeyIsSet([
2627
'user_id' => null,
2728
'name' => $this->faker->company,
2829
'secret' => Str::random(40),
2930
'redirect' => $this->faker->url,
3031
'personal_access_client' => false,
3132
'password_client' => false,
3233
'revoked' => false,
33-
];
34+
]);
35+
}
36+
37+
/**
38+
* Ensure the primary key is set on the model when using UUIDs.
39+
*
40+
* @param array $data
41+
* @return array
42+
*/
43+
protected function ensurePrimaryKeyIsSet(array $data)
44+
{
45+
if (Passport::clientUuids()) {
46+
$keyName = (new $this->model)->getKeyName();
47+
48+
$data[$keyName] = (string) Str::orderedUuid();
49+
}
50+
51+
return $data;
3452
}
3553

3654
/**

src/Http/Middleware/CheckCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function handle($request, Closure $next, ...$scopes)
7272
/**
7373
* Validate the scopes and token on the incoming request.
7474
*
75-
* @param \Psr\Http\Message\ServerRequestInterface $psr
75+
* @param \Psr\Http\Message\ServerRequestInterface $psr
7676
* @param array $scopes
7777
* @return void
7878
*

src/Passport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ public static function actingAs($user, $scopes = [], $guard = 'api')
345345
/**
346346
* Set the current client for the application with the given scopes.
347347
*
348-
* @param \Laravel\Passport\Client $client
349-
* @param array $scopes
348+
* @param \Laravel\Passport\Client $client
349+
* @param array $scopes
350350
* @return \Laravel\Passport\Client
351351
*/
352352
public static function actingAsClient($client, $scopes = [])

tests/Feature/AccessTokenControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ public function testGettingAccessTokenWithPasswordGrantWithInvalidPassword()
216216
$this->assertArrayNotHasKey('expires_in', $decodedResponse);
217217
$this->assertArrayNotHasKey('access_token', $decodedResponse);
218218
$this->assertArrayNotHasKey('refresh_token', $decodedResponse);
219+
$this->assertArrayNotHasKey('hint', $decodedResponse);
219220

220221
$this->assertArrayHasKey('error', $decodedResponse);
221222
$this->assertSame('invalid_grant', $decodedResponse['error']);
222223
$this->assertArrayHasKey('error_description', $decodedResponse);
223-
$this->assertArrayHasKey('hint', $decodedResponse);
224224
$this->assertArrayHasKey('message', $decodedResponse);
225225

226226
$this->assertSame(0, Token::count());

tests/Unit/PassportServiceProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function test_can_use_crypto_keys_from_config()
3434

3535
$this->assertSame(
3636
$privateKeyString,
37-
file_get_contents($cryptKey->getKeyPath())
37+
$cryptKey->getKeyContents()
3838
);
3939
}
4040

0 commit comments

Comments
 (0)