diff --git a/backend/handler/email.go b/backend/handler/email.go index f63d4936c..76a8bbd81 100644 --- a/backend/handler/email.go +++ b/backend/handler/email.go @@ -141,7 +141,16 @@ func (h *EmailHandler) Create(c echo.Context) error { } if !h.cfg.Emails.RequireVerification { - utils.NotifyUserChange(c, tx, h.persister, events.EmailCreate, userId) + var evt events.Event + + if len(user.Emails) >= 1 { + evt = events.EmailCreate + } else { + evt = events.UserCreate + } + + utils.NotifyUserChange(c, tx, h.persister, evt, userId) + } return c.JSON(http.StatusOK, email) diff --git a/backend/handler/passcode.go b/backend/handler/passcode.go index 2ea99ba69..3ec6c129b 100644 --- a/backend/handler/passcode.go +++ b/backend/handler/passcode.go @@ -384,7 +384,15 @@ func (h *PasscodeHandler) Finish(c echo.Context) error { // notify about email verification result. Last step to prevent a trigger and rollback scenario if h.cfg.Emails.RequireVerification && wasUnverified { - utils.NotifyUserChange(c, tx, h.persister, events.EmailCreate, user.ID) + var evt events.Event + + if len(user.Emails) >= 1 { + evt = events.EmailCreate + } else { + evt = events.UserCreate + } + + utils.NotifyUserChange(c, tx, h.persister, evt, user.ID) } return c.JSON(http.StatusOK, dto.PasscodeReturn{