Compare commits

...

1 Commits

Author SHA1 Message Date
Neeraj Gupta
31057cbe9e [server] Handle mobile flag 2025-08-20 14:51:30 +05:30
3 changed files with 5 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ type SendOTTRequest struct {
Email string `json:"email"` Email string `json:"email"`
Client string `json:"client"` Client string `json:"client"`
Purpose string `json:"purpose"` Purpose string `json:"purpose"`
Mobile bool `json:"mobile,omitempty"`
} }
// EmailVerificationRequest represents an email verification request // 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")) handler.Error(c, stacktrace.Propagate(ente.ErrBadRequest, "Email id is missing"))
return return
} }
err := h.UserController.SendEmailOTT(c, email, request.Purpose) err := h.UserController.SendEmailOTT(c, email, request.Purpose, request.Mobile)
if err != nil { if err != nil {
handler.Error(c, stacktrace.Propagate(err, "")) handler.Error(c, stacktrace.Propagate(err, ""))
return 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 // 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 { if err := c.validateSendOTT(context, email, purpose); err != nil {
return err return err
} }
@@ -119,7 +119,7 @@ func (c *UserController) SendEmailOTT(context *gin.Context, email string, purpos
return stacktrace.Propagate(err, "") return stacktrace.Propagate(err, "")
} }
log.Info("Added ott for " + emailHash + ": " + ott) log.Info("Added ott for " + emailHash + ": " + ott)
err = emailOTT(email, ott, purpose) err = emailOTT(email, ott, purpose, viaMobile)
if err != nil { if err != nil {
return stacktrace.Propagate(err, "") 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), "") 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 var templateName string
if purpose == ente.ChangeEmailOTTPurpose { if purpose == ente.ChangeEmailOTTPurpose {
templateName = ente.ChangeEmailOTTTemplate templateName = ente.ChangeEmailOTTTemplate