Skip to content

Commit

Permalink
[5.7] Do not send email verification if user is already verified (#25450
Browse files Browse the repository at this point in the history
)

Hey guys,

So I'm using Socialite to register users. I'm dispatching the Registered event and since my model now extends MustVerifyEmail, it sends out an email to users which are already verified (force filled by my FB/Google integration).

This makes sure that a "verified" user does not receive the email, so if in your registration process you mark them as verified, they will not receive the email.
  • Loading branch information
Francismori7 authored and taylorotwell committed Sep 5, 2018
1 parent 8021279 commit 71cf99b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SendEmailVerificationNotification
*/
public function handle(Registered $event)
{
if ($event->user instanceof MustVerifyEmail) {
if ($event->user instanceof MustVerifyEmail && ! $event->user->hasVerifiedEmail()) {
$event->user->sendEmailVerificationNotification();
}
}
Expand Down

2 comments on commit 71cf99b

@hasokeric
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@bbashy
Copy link
Contributor

@bbashy bbashy commented on 71cf99b Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just about to submit this!

Please sign in to comment.