mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +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)
|
cache := utils.GetCacheFromContext(c)
|
||||||
code := generateCode(c, cache, email)
|
code := generateCode(c, cache, email)
|
||||||
|
|
||||||
provider := channel.SystemInstance.GetMail()
|
return channel.SystemInstance.SendVerifyMail(email, code)
|
||||||
|
|
||||||
type Temp struct {
|
|
||||||
Code string `json:"code"`
|
|
||||||
}
|
|
||||||
|
|
||||||
return provider.RenderMail(
|
|
||||||
"code.html",
|
|
||||||
Temp{Code: code},
|
|
||||||
email,
|
|
||||||
"Chat Nio | OTP Verification",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SignUp(c *gin.Context, form RegisterForm) (string, error) {
|
func SignUp(c *gin.Context, form RegisterForm) (string, error) {
|
||||||
|
@ -2,7 +2,9 @@ package channel
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"chat/utils"
|
"chat/utils"
|
||||||
|
"fmt"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApiInfo struct {
|
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 {
|
func (c *SystemConfig) GetSearchEndpoint() string {
|
||||||
if len(c.Search.Endpoint) == 0 {
|
if len(c.Search.Endpoint) == 0 {
|
||||||
return "https://duckduckgo-api.vercel.app"
|
return "https://duckduckgo-api.vercel.app"
|
||||||
@ -98,3 +115,21 @@ func (c *SystemConfig) GetSearchQuery() int {
|
|||||||
|
|
||||||
return c.Search.Query
|
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>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<div class="main">
|
<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"><p>Your One-Time Password is <strong class="code">{{.Code}}</strong></p></div>
|
||||||
<div class="column" style="color:gray">
|
<div class="column" style="color:gray">
|
||||||
<span>The code will expire in <strong>10 minutes</strong>.</span><br>
|
<span>The code will expire in <strong>10 minutes</strong>.</span><br>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<a href="">© Chat Nio</a>
|
<a href="">© {{.Title}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
Loading…
Reference in New Issue
Block a user