mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 04:50:14 +09:00
update email form render
This commit is contained in:
parent
4efd0e8928
commit
11a4f3dd2f
13
auth/auth.go
13
auth/auth.go
@ -94,18 +94,7 @@ func Verify(c *gin.Context, email string) error {
|
||||
cache := utils.GetCacheFromContext(c)
|
||||
code := generateCode(c, cache, email)
|
||||
|
||||
provider := channel.SystemInstance.GetMail()
|
||||
|
||||
type Temp struct {
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
return provider.RenderMail(
|
||||
"code.html",
|
||||
Temp{Code: code},
|
||||
email,
|
||||
"Chat Nio | OTP Verification",
|
||||
)
|
||||
return channel.SystemInstance.SendVerifyMail(email, code)
|
||||
}
|
||||
|
||||
func SignUp(c *gin.Context, form RegisterForm) (string, error) {
|
||||
|
@ -2,7 +2,9 @@ package channel
|
||||
|
||||
import (
|
||||
"chat/utils"
|
||||
"fmt"
|
||||
"github.com/spf13/viper"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ApiInfo struct {
|
||||
@ -83,6 +85,21 @@ func (c *SystemConfig) GetMail() *utils.SmtpPoster {
|
||||
)
|
||||
}
|
||||
|
||||
func (c *SystemConfig) SendVerifyMail(email string, code string) error {
|
||||
type Temp struct {
|
||||
Title string `json:"title"`
|
||||
Logo string `json:"logo"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
return c.GetMail().RenderMail(
|
||||
"code.html",
|
||||
Temp{Title: c.GetAppName(), Logo: c.GetAppLogo(), Code: code},
|
||||
email,
|
||||
fmt.Sprintf("%s | OTP Verification", c.GetAppName()),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *SystemConfig) GetSearchEndpoint() string {
|
||||
if len(c.Search.Endpoint) == 0 {
|
||||
return "https://duckduckgo-api.vercel.app"
|
||||
@ -98,3 +115,21 @@ func (c *SystemConfig) GetSearchQuery() int {
|
||||
|
||||
return c.Search.Query
|
||||
}
|
||||
|
||||
func (c *SystemConfig) GetAppName() string {
|
||||
title := strings.TrimSpace(c.General.Title)
|
||||
if len(title) == 0 {
|
||||
return "Chat Nio"
|
||||
}
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
func (c *SystemConfig) GetAppLogo() string {
|
||||
logo := strings.TrimSpace(c.General.Logo)
|
||||
if len(logo) == 0 {
|
||||
return "https://chatnio.net/favicon.ico"
|
||||
}
|
||||
|
||||
return logo
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
</style>
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="column"><img src="https://chatnio.net/favicon.ico" alt=""><h1>Chat Nio</h1></div>
|
||||
<div class="column"><img src="{{.Logo}}" alt=""><h1>{{.Title}}</h1></div>
|
||||
<div class="column"><p>Your One-Time Password is <strong class="code">{{.Code}}</strong></p></div>
|
||||
<div class="column" style="color:gray">
|
||||
<span>The code will expire in <strong>10 minutes</strong>.</span><br>
|
||||
@ -46,7 +46,7 @@
|
||||
</div>
|
||||
<br>
|
||||
<div class="column">
|
||||
<a href="">© Chat Nio</a>
|
||||
<a href="">© {{.Title}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user