backend: always update `last_verification_sent_at` column after trying to send email
Created by: unknwon
Our code logic for calculating email sending cooldown consults the value of the user_emails.last_verification_sent_at
column, however, if the email didn't get sent in the first place due to any reason, the column is NULL, and resend is impossible. The user would have to first remove and re-add the same email.
Fixes https://github.com/sourcegraph/sourcegraph/issues/36632
Test plan
Manul e2e test and unit test.
- Use a bad credential for the site config
"email.smtp"
(simulate email sending failures) - Add a new email under the user Settings > Emails (any random fake email, shouldn't be verified already by other users)
- Refresh the page, click "Resend verification email"
- Should see "Last verification email sent too recently" instead of "user email not found [...]"