forked from nixcn/nixcn-cms
@@ -5,6 +5,7 @@ import (
|
||||
"net/url"
|
||||
"nixcn-cms/data"
|
||||
"nixcn-cms/internal/crypto/jwt"
|
||||
"nixcn-cms/pkgs/email"
|
||||
"nixcn-cms/pkgs/magiclink"
|
||||
"nixcn-cms/pkgs/turnstile"
|
||||
|
||||
@@ -41,16 +42,26 @@ func RequestMagicLink(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
link, err := url.JoinPath(viper.GetString("server.external_url"), "/api/v1/auth/magic/verify?token="+token)
|
||||
link, err := url.JoinPath(viper.GetString("server.external_url"), "/login?ticket="+token)
|
||||
if err != nil {
|
||||
log.Error("Magic link join failed!")
|
||||
c.JSON(500, gin.H{"message": "magic link join failed"})
|
||||
c.JSON(500, gin.H{"status": "magic link join failed"})
|
||||
return
|
||||
}
|
||||
|
||||
// TODO send email
|
||||
// Send email using resend
|
||||
resend, err := email.NewResendClient()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
c.JSON(500, gin.H{"status": "invilad email config"})
|
||||
}
|
||||
resend.Send(
|
||||
req.Email,
|
||||
"NixCN CSM Email Verify",
|
||||
"Click the link below to verify your email. This link will expire in 10 minutes.\n"+link,
|
||||
)
|
||||
|
||||
c.JSON(200, gin.H{"message": "magic link sent", "magic_link": link})
|
||||
c.JSON(200, gin.H{"status": "magic link sent"})
|
||||
}
|
||||
|
||||
func VerifyMagicLink(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user