mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
passes subject and email body as parameters
This commit is contained in:
parent
b521f4bfa9
commit
1bb3370e07
3 changed files with 15 additions and 4 deletions
|
@ -189,7 +189,7 @@ func NewClient() echo.HandlerFunc {
|
|||
}
|
||||
|
||||
// EmailClient handler to sent the configuration via email
|
||||
func EmailClient(mailer emailer.Emailer) echo.HandlerFunc {
|
||||
func EmailClient(mailer emailer.Emailer, emailSubject, emailContent string) echo.HandlerFunc {
|
||||
type clientIdEmailPayload struct {
|
||||
ID string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
|
@ -220,8 +220,8 @@ func EmailClient(mailer emailer.Emailer) echo.HandlerFunc {
|
|||
err = mailer.Send(
|
||||
clientData.Client.Name,
|
||||
payload.Email,
|
||||
"Your Wireguard configuration",
|
||||
"instructions here",
|
||||
emailSubject,
|
||||
emailContent,
|
||||
[]emailer.Attachment{cfg_att, qr_att},
|
||||
)
|
||||
if err != nil {
|
||||
|
|
11
main.go
11
main.go
|
@ -24,6 +24,15 @@ var (
|
|||
buildTime = fmt.Sprintf(time.Now().UTC().Format("01-02-2006 15:04:05"))
|
||||
)
|
||||
|
||||
const (
|
||||
defaultEmailSubject = "Your wireguard configuration"
|
||||
defaultEmailContent = `Hi,</br>
|
||||
<p>in this email you can file your personal configuration for our wireguard server.</p>
|
||||
|
||||
<p>Best</p>
|
||||
`
|
||||
)
|
||||
|
||||
func init() {
|
||||
// command-line flags
|
||||
flagDisableLogin := flag.Bool("disable-login", false, "Disable login page. Turn off authentication.")
|
||||
|
@ -81,7 +90,7 @@ func main() {
|
|||
app.GET("/logout", handler.Logout(), handler.ValidSession)
|
||||
app.POST("/new-client", handler.NewClient(), handler.ValidSession)
|
||||
app.POST("/update-client", handler.UpdateClient(), handler.ValidSession)
|
||||
app.POST("/email-client", handler.EmailClient(sendmail), handler.ValidSession)
|
||||
app.POST("/email-client", handler.EmailClient(sendmail, defaultEmailSubject, defaultEmailContent), handler.ValidSession)
|
||||
app.POST("/client/set-status", handler.SetClientStatus(), handler.ValidSession)
|
||||
app.POST("/remove-client", handler.RemoveClient(), handler.ValidSession)
|
||||
app.GET("/download", handler.DownloadClient(), handler.ValidSession)
|
||||
|
|
|
@ -7,5 +7,7 @@ var (
|
|||
SendgridApiKey string
|
||||
EmailFrom string
|
||||
EmailFromName string
|
||||
EmailSubject string
|
||||
EmailContent string
|
||||
SessionSecret []byte
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue