[server] Handle mobile flag

This commit is contained in:
Neeraj Gupta
2025-08-20 14:51:30 +05:30
parent fc1096c985
commit 31057cbe9e
3 changed files with 5 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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