Compare commits
1 Commits
testing-fe
...
send_ott
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31057cbe9e |
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user