From a49450bf9e6ddb6857f82747b01d63d585f34cd9 Mon Sep 17 00:00:00 2001 From: Noa Virellia Date: Sun, 28 Dec 2025 17:41:13 +0800 Subject: [PATCH] feat(auth/magic): log to console instead of sending email in debug mode Signed-off-by: Noa Virellia --- service/auth/magic.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/service/auth/magic.go b/service/auth/magic.go index 68fa761..8ba2271 100644 --- a/service/auth/magic.go +++ b/service/auth/magic.go @@ -44,18 +44,23 @@ func RequestMagicLink(c *gin.Context) { link := viper.GetString("server.external_url") + "/login?ticket=" + token - // Send email using resend - resend, err := email.NewResendClient() - if err != nil { - log.Error(err) - c.JSON(500, gin.H{"status": "invilad email config"}) - return + debugMode := viper.GetString("server.debug_mode") + if debugMode == "true" { + log.Info("Magic link for " + req.Email + " : " + link) + } else { + // Send email using resend + 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", + "

Click the link below to verify your email. This link will expire in 10 minutes.

"+link+"", + ) } - resend.Send( - req.Email, - "NixCN CMS Email Verify", - "

Click the link below to verify your email. This link will expire in 10 minutes.

"+link+"", - ) c.JSON(200, gin.H{"status": "magic link sent"}) }