fix(notify): add verification flow for saved unverified emails

- Add "verify" button next to saved unverified emails in
  ProfileBalanceNotifyCard (send code → enter code → verify)
- Backend: VerifyAndAddNotifyEmail now marks existing unverified
  emails as verified instead of returning "already exists"
- Inline verification UI with countdown timer and resend button
This commit is contained in:
erio
2026-04-13 01:40:13 +08:00
parent 31550a2c6a
commit 95f9b27e70
2 changed files with 88 additions and 5 deletions

View File

@@ -336,14 +336,18 @@ func (s *UserService) VerifyAndAddNotifyEmail(ctx context.Context, userID int64,
return err
}
// Check if already exists
for _, e := range user.BalanceNotifyExtraEmails {
// Check if already exists — if unverified, mark as verified
for i, e := range user.BalanceNotifyExtraEmails {
if strings.EqualFold(e.Email, email) {
return nil // Already added
if !e.Verified {
user.BalanceNotifyExtraEmails[i].Verified = true
return s.userRepo.Update(ctx, user)
}
return nil // Already verified
}
}
// Check limit (total includes primary email="" placeholder + extra emails)
// Check limit
if len(user.BalanceNotifyExtraEmails) >= maxNotifyEmails {
return infraerrors.BadRequest("TOO_MANY_NOTIFY_EMAILS", fmt.Sprintf("maximum %d notification emails allowed", maxNotifyEmails))
}