5 months ago

Send verification e-mail, when it is changed by user

Posted 5 months ago by Mego

Hello, I am developing a system with users, which must have their e-mail addresses verified. In registration that is OK by almost default laravel function (with used vue auth). However, I can give users an opinion, to change their e-mail address any time.

So I have stored users in my DB, and they have "email" column and "email_verified_at" column. When user is registrated, the verification e-mail is sent, and "email_verified_at" is default set to NULL. This is OK.

When user change his e-mail inside my app, as logged user, I have two problems:

1 How can I set NULL value again to the "email_verified_at"? It is datetime, so when user has his email verified, the date and time is stored there. When he change the e-mail address, I need to set this value again to NULL, how can I do that? I have this query:

$doIt = DB::table('users')->where('id', $user_id)->update(['email' => $emails['email'], 'email_verified_at' => NULL]);

I am afraid, that this doesn't work.

2 How can I force Laravel to send new verification e-mail with verification link? Is here any method or something like this?

Thank you a million for a help. Have a nice day!

Please sign in or create an account to participate in this conversation.