Skip to content

Commit

Permalink
Fix: missing dispatch call for the releaseEvents for fireing the Emai…
Browse files Browse the repository at this point in the history
…lChanged event (#87)

* fix: missing release of registered evenrts

* chore: format

* fix: dispatch the released events

* chore: format
  • Loading branch information
novacuum authored Nov 28, 2024
1 parent e9f403c commit 380efc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Jobs/CheckAndUpdateUserEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Flarum\User\User;
use Flarum\User\UserValidator;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;

Expand Down Expand Up @@ -51,7 +52,7 @@ public function __construct(string $providerName, $identifier, ?string $provided
$this->providedEmail = $providedEmail;
}

public function handle(UserValidator $validator)
public function handle(UserValidator $validator, Dispatcher $events)
{
$provider = LoginProvider::where('provider', $this->providerName)->where('identifier', $this->identifier)->first();

Expand All @@ -76,7 +77,9 @@ public function handle(UserValidator $validator)
$user->changeEmail($this->providedEmail);

$user->save();
$user->releaseEvents();
foreach ($user->releaseEvents() as $event) {
$events->dispatch($event);
}
}
}
}

0 comments on commit 380efc5

Please sign in to comment.