diff --git a/server/ente/user.go b/server/ente/user.go index 8b207712d9..cc39c9b42a 100644 --- a/server/ente/user.go +++ b/server/ente/user.go @@ -31,6 +31,7 @@ type SendOTTRequest struct { Email string `json:"email"` Client string `json:"client"` Purpose string `json:"purpose"` + Mobile bool `json:"mobile,omitempty"` } // EmailVerificationRequest represents an email verification request diff --git a/server/pkg/api/user.go b/server/pkg/api/user.go index 2f588da6b9..8e791ad55f 100644 --- a/server/pkg/api/user.go +++ b/server/pkg/api/user.go @@ -40,7 +40,7 @@ func (h *UserHandler) SendOTT(c *gin.Context) { handler.Error(c, stacktrace.Propagate(ente.ErrBadRequest, "Email id is missing")) return } - err := h.UserController.SendEmailOTT(c, email, request.Purpose) + err := h.UserController.SendEmailOTT(c, email, request.Purpose, request.Mobile) if err != nil { handler.Error(c, stacktrace.Propagate(err, "")) return diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.go index ae20dff124..bd4e2ddf80 100644 --- a/server/pkg/controller/user/userauth.go +++ b/server/pkg/controller/user/userauth.go @@ -82,7 +82,7 @@ func hardcodedOTTForEmail(hardCodedOTT HardCodedOTT, email string) string { } // SendEmailOTT generates and sends an OTT to the provided email address -func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpose string) error { +func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpose string, viaMobile bool) error { if err := c.validateSendOTT(context, email, purpose); err != nil { return err } @@ -119,7 +119,7 @@ func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpos return stacktrace.Propagate(err, "") } log.Info("Added ott for " + emailHash + ": " + ott) - err = emailOTT(email, ott, purpose) + err = emailOTT(email, ott, purpose, viaMobile) if err != nil { return stacktrace.Propagate(err, "") } @@ -383,7 +383,7 @@ func (c *UserController) TerminateSession(userID int64, token string) error { return stacktrace.Propagate(c.UserAuthRepo.RemoveToken(userID, token), "") } -func emailOTT(to string, ott string, purpose string) error { +func emailOTT(to string, ott string, purpose string, viaMobile bool) error { var templateName string if purpose == ente.ChangeEmailOTTPurpose { templateName = ente.ChangeEmailOTTTemplate