| 689 | } |
| 690 | |
| 691 | func (a *API) sendMFAFactorUnenrolledNotification(r *http.Request, tx *storage.Connection, u *models.User, factorType string) error { |
| 692 | err := a.sendEmail(r, tx, u, sendEmailParams{ |
| 693 | emailActionType: mail.MFAFactorUnenrolledNotification, |
| 694 | factorType: factorType, |
| 695 | }) |
| 696 | if err != nil { |
| 697 | if errors.Is(err, EmailRateLimitExceeded) { |
| 698 | return apierrors.NewTooManyRequestsError(apierrors.ErrorCodeOverEmailSendRateLimit, "%s", EmailRateLimitExceeded.Error()) |
| 699 | } else if herr, ok := err.(*HTTPError); ok { |
| 700 | return herr |
| 701 | } |
| 702 | return apierrors.NewInternalServerError("Error sending MFA factor unenrolled notification email").WithInternalError(err) |
| 703 | } |
| 704 | |
| 705 | return nil |
| 706 | } |
| 707 | |
| 708 | func (a *API) validateEmail(email string) (string, error) { |
| 709 | if email == "" { |