Do not send email in debug mode #3
2
justfile
2
justfile
@@ -9,7 +9,7 @@ bun_cmd := `realpath $(which bun)`
|
|||||||
|
|
||||||
default: install clean build-back build-client run-back
|
default: install clean build-back build-client run-back
|
||||||
|
|
||||||
backend: install clean build-back run-back
|
backend: clean build-back run-back
|
||||||
|
|
||||||
install:
|
install:
|
||||||
cd {{ client_dir }} && {{ bun_cmd }} install
|
cd {{ client_dir }} && {{ bun_cmd }} install
|
||||||
|
|||||||
@@ -44,11 +44,15 @@ func RequestMagicLink(c *gin.Context) {
|
|||||||
|
|
||||||
link := viper.GetString("server.external_url") + "/login?ticket=" + token
|
link := viper.GetString("server.external_url") + "/login?ticket=" + token
|
||||||
|
|
||||||
|
debugMode := viper.GetString("server.debug_mode")
|
||||||
|
if debugMode == "true" {
|
||||||
|
log.Info("Magic link for " + req.Email + " : " + link)
|
||||||
|
} else {
|
||||||
// Send email using resend
|
// Send email using resend
|
||||||
resend, err := email.NewResendClient()
|
resend, err := email.NewResendClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
c.JSON(500, gin.H{"status": "invilad email config"})
|
c.JSON(500, gin.H{"status": "invalid email config"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resend.Send(
|
resend.Send(
|
||||||
@@ -56,6 +60,7 @@ func RequestMagicLink(c *gin.Context) {
|
|||||||
"NixCN CMS Email Verify",
|
"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>",
|
"<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