Skip to content

Commit

Permalink
Fix HashCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed May 14, 2020
1 parent b8657e3 commit bedf02c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Console/HashCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HashCommand extends Command
public function handle()
{
if (! Passport::$hashesClientSecrets) {
$this->warn('Please enable client hashing yet in your AppServiceProvider before continuning.');
$this->warn('Please enable client hashing yet in your AppServiceProvider before continuing.');

return;
}
Expand All @@ -45,7 +45,7 @@ public function handle()
$client->timestamps = false;

$client->forceFill([
'secret' => password_hash($client->secret, PASSWORD_BCRYPT),
'secret' => $client->secret,
])->save();
}

Expand Down
26 changes: 26 additions & 0 deletions tests/Feature/Console/HashCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Laravel\Passport\Tests\Feature\Console;

use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Support\Str;
use Laravel\Passport\Client;
use Laravel\Passport\Passport;
use Laravel\Passport\Tests\Feature\PassportTestCase;

class HashCommand extends PassportTestCase
{
public function test_it_can_properly_has_client_secrets()
{
$client = factory(Client::class)->create(['secret' => $secret = Str::random(40)]);
$hasher = $this->app->make(Hasher::class);

Passport::hashClientSecrets();

$this->artisan('passport:hash', ['--force' => true]);

$this->assertTrue($hasher->check($secret, $client->refresh()->secret));

Passport::$hashesClientSecrets = false;
}
}

0 comments on commit bedf02c

Please sign in to comment.