First off, I've followed every step in the docs without success. I then dug into the getVerification
method handling email verification requests, and went all the way down to Jrean\UserVerification\UserVerification, where they have wasVerified($user)
$user->verification_token = null;
$user->verified = true;
$user->verified_at = now();
$this->updateUser($user);
event(new UserVerified($user));
So I swapped out the default event in the docs, which I was dispatching in my override of getVerification
in RegisterController
default EventServiceProvider from docs
protected $listen = [
'Illuminate\Auth\Events\Verified' => [ // then replaced event name with 'Jrean\UserVerification\Events\UserVerified'
'App\Listeners\LogVerifiedUser',
],
];
I also tried listening to both events i.e. firing mine as well in my RegisterController
use VerifiesUsers {
getVerification as parentVerification;
}
public function getVerification(Request $request, $token) {
$this->parentVerification($request, $token);
event(new Verified(\Auth::user()));
Then I dd
ed something (either in the listener or before manually emitting the event in the controller above) and the DB insert in my listener ran seamlessly. However, there was no redirect afterwards. I removed the dd
, believing all to be well and fine, now the behaviour has become even more inscrutable: after "verification", those columns in wasVerified()
never get updated in that user's row. Everything is stagnant, yet the user can perform all actions accessible to a verified user. At the same time, either none of the events fire or the listener is deaf.
I tried following the mocking events docs but I don't know how to go about replicating user verification in a test environment. But even if I did, it will just tell me whether the event is fired in the first place, not directly solving the problem at hand.
Finally, I tried manually calling my target handler (both with and without the aid of events) but nothing happens. It just gets into the parent verifier and redirects to the homepage.
Is there any other way of running a desired action after a user is verified?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire