Skip to content

Commit bedf02c

Browse files
committed
Fix HashCommand
1 parent b8657e3 commit bedf02c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Console/HashCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class HashCommand extends Command
2929
public function handle()
3030
{
3131
if (! Passport::$hashesClientSecrets) {
32-
$this->warn('Please enable client hashing yet in your AppServiceProvider before continuning.');
32+
$this->warn('Please enable client hashing yet in your AppServiceProvider before continuing.');
3333

3434
return;
3535
}
@@ -45,7 +45,7 @@ public function handle()
4545
$client->timestamps = false;
4646

4747
$client->forceFill([
48-
'secret' => password_hash($client->secret, PASSWORD_BCRYPT),
48+
'secret' => $client->secret,
4949
])->save();
5050
}
5151

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Laravel\Passport\Tests\Feature\Console;
4+
5+
use Illuminate\Contracts\Hashing\Hasher;
6+
use Illuminate\Support\Str;
7+
use Laravel\Passport\Client;
8+
use Laravel\Passport\Passport;
9+
use Laravel\Passport\Tests\Feature\PassportTestCase;
10+
11+
class HashCommand extends PassportTestCase
12+
{
13+
public function test_it_can_properly_has_client_secrets()
14+
{
15+
$client = factory(Client::class)->create(['secret' => $secret = Str::random(40)]);
16+
$hasher = $this->app->make(Hasher::class);
17+
18+
Passport::hashClientSecrets();
19+
20+
$this->artisan('passport:hash', ['--force' => true]);
21+
22+
$this->assertTrue($hasher->check($secret, $client->refresh()->secret));
23+
24+
Passport::$hashesClientSecrets = false;
25+
}
26+
}

0 commit comments

Comments
 (0)