Do not send email in debug mode #3
@@ -44,18 +44,23 @@ func RequestMagicLink(c *gin.Context) {
|
|||||||
|
|
||||||
link := viper.GetString("server.external_url") + "/login?ticket=" + token
|
link := viper.GetString("server.external_url") + "/login?ticket=" + token
|
||||||
|
|
||||||
// Send email using resend
|
debugMode := viper.GetString("server.debug_mode")
|
||||||
resend, err := email.NewResendClient()
|
if debugMode == "true" {
|
||||||
if err != nil {
|
log.Info("Magic link for " + req.Email + " : " + link)
|
||||||
log.Error(err)
|
} else {
|
||||||
c.JSON(500, gin.H{"status": "invilad email config"})
|
// Send email using resend
|
||||||
return
|
resend, err := email.NewResendClient()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
c.JSON(500, gin.H{"status": "invalid email config"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resend.Send(
|
||||||
|
req.Email,
|
||||||
|
"NixCN CMS Email Verify",
|
||||||
|
"<p>Click the link below to verify your email. This link will expire in 10 minutes.</p><a href="+link+">"+link+"</a>",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
resend.Send(
|
|
||||||
req.Email,
|
|
||||||
"NixCN CMS Email Verify",
|
|
||||||
"<p>Click the link below to verify your email. This link will expire in 10 minutes.</p><a href="+link+">"+link+"</a>",
|
|
||||||
)
|
|
||||||
|
|
||||||
c.JSON(200, gin.H{"status": "magic link sent"})
|
c.JSON(200, gin.H{"status": "magic link sent"})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user