Use filaments password broker for reset link token when creating subuser (#1498)

This commit is contained in:
Boy132 2025-07-19 18:51:42 +02:00 committed by GitHub
parent 340d1b543c
commit 9f2305f351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,15 +7,16 @@ use Ramsey\Uuid\Uuid;
use App\Models\User; use App\Models\User;
use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Illuminate\Contracts\Auth\PasswordBroker;
use App\Notifications\AccountCreated; use App\Notifications\AccountCreated;
use Filament\Facades\Filament;
use Illuminate\Auth\Passwords\PasswordBroker;
use Illuminate\Support\Facades\Password;
class UserCreationService class UserCreationService
{ {
public function __construct( public function __construct(
private readonly ConnectionInterface $connection, private readonly ConnectionInterface $connection,
private readonly Hasher $hasher, private readonly Hasher $hasher,
private readonly PasswordBroker $passwordBroker,
) {} ) {}
/** /**
@ -51,7 +52,9 @@ class UserCreationService
} }
if (isset($generateResetToken)) { if (isset($generateResetToken)) {
$token = $this->passwordBroker->createToken($user); /** @var PasswordBroker $broker */
$broker = Password::broker(Filament::getPanel('app')->getAuthPasswordBroker());
$token = $broker->createToken($user);
} }
$this->connection->commit(); $this->connection->commit();