feat: users.email_verified_at records a proved address (mail activation, reset code)

- additive migration 202610210001_add_users_email_verified_at (ADD COLUMN IF NOT EXISTS, no backfill, no-op rollback)
- User.EmailVerifiedAt (json:"-", not fillable)
- VerifyActivationCode and ResetPassword stamp it in the write that activates or stores the password
This commit is contained in:
Jakub Zych
2026-10-21 13:53:19 +02:00
parent c7635c56e3
commit add1f7a806
6 changed files with 59 additions and 3 deletions

View File

@@ -329,10 +329,14 @@ func ResetPassword(app *backpack.App) http.HandlerFunc {
writeOpaque500(w)
return
}
// The reset code was mailed to the account's address, so the write
// that stores the new password also records the proof of that
// address (D-27). A reset that fails here records nothing.
now := time.Now()
if err := gdb.WithContext(r.Context()).Model(&models.User{}).Where("id = ?", user.ID).Updates(map[string]any{
"password": hashed,
"tokens_valid_after": now,
"email_verified_at": now,
}).Error; err != nil {
writeOpaque500(w)
return