mirror of
https://github.com/1f349/lavender.git
synced 2025-01-21 06:06:30 +00:00
Fix the mail configuration
This commit is contained in:
parent
196fd74d45
commit
6d09792e59
@ -8,6 +8,7 @@ import (
|
||||
"github.com/1f349/lavender/conf"
|
||||
"github.com/1f349/lavender/database"
|
||||
"github.com/1f349/lavender/logger"
|
||||
"github.com/1f349/lavender/mail"
|
||||
"github.com/1f349/lavender/role"
|
||||
"github.com/1f349/lavender/server"
|
||||
"github.com/1f349/lavender/web"
|
||||
@ -96,6 +97,11 @@ func (s *serveCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{})
|
||||
}
|
||||
wd := filepath.Dir(configPathAbs)
|
||||
|
||||
mailSender, err := mail.New(&config.Mail, wd, "")
|
||||
if err != nil {
|
||||
logger.Logger.Fatal("Failed to create mail sender", "err", err)
|
||||
}
|
||||
|
||||
// load the keystore private and public keys
|
||||
keyDir := filepath.Join(wd, "keystore")
|
||||
err = os.MkdirAll(keyDir, 0700)
|
||||
@ -131,7 +137,7 @@ func (s *serveCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{})
|
||||
}
|
||||
|
||||
mux := httprouter.New()
|
||||
server.SetupRouter(mux, config, db, signingKey)
|
||||
server.SetupRouter(mux, config, mailSender, db, signingKey)
|
||||
srv := &http.Server{
|
||||
Handler: mux,
|
||||
ReadTimeout: time.Minute,
|
||||
|
@ -2,7 +2,7 @@ package conf
|
||||
|
||||
import (
|
||||
"github.com/1f349/lavender/issuer"
|
||||
"github.com/1f349/lavender/mail"
|
||||
"github.com/1f349/simplemail"
|
||||
)
|
||||
|
||||
type Conf struct {
|
||||
@ -13,6 +13,6 @@ type Conf struct {
|
||||
Kid string `yaml:"kid"`
|
||||
Namespace string `yaml:"namespace"`
|
||||
OtpIssuer string `yaml:"otpIssuer"`
|
||||
Mail mail.Mail `yaml:"mail"`
|
||||
Mail simplemail.Mail `yaml:"mail"`
|
||||
SsoServices []issuer.SsoConfig `yaml:"ssoServices"`
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func (h *httpServer) MailDelete(rw http.ResponseWriter, req *http.Request, param
|
||||
return
|
||||
}
|
||||
|
||||
err = h.conf.Mail.SendEmailTemplate("mail-account-delete", "Account Deletion", userInfo.Name, address, nil)
|
||||
err = h.mailSender.SendEmailTemplate("mail-account-delete", "Account Deletion", userInfo.Name, address, nil)
|
||||
if err != nil {
|
||||
http.Error(rw, "Failed to send confirmation email.", http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/1f349/lavender/database"
|
||||
"github.com/1f349/lavender/issuer"
|
||||
"github.com/1f349/lavender/logger"
|
||||
"github.com/1f349/lavender/mail"
|
||||
"github.com/1f349/lavender/web"
|
||||
"github.com/1f349/mjwt"
|
||||
"github.com/go-oauth2/oauth2/v4/manage"
|
||||
@ -28,6 +29,7 @@ type httpServer struct {
|
||||
db *database.Queries
|
||||
conf conf.Conf
|
||||
signingKey *mjwt.Issuer
|
||||
mailSender *mail.Mail
|
||||
manager *issuer.Manager
|
||||
|
||||
// mailLinkCache contains a mapping of verify uuids to user uuids
|
||||
@ -53,7 +55,7 @@ type mailLinkKey struct {
|
||||
data string
|
||||
}
|
||||
|
||||
func SetupRouter(r *httprouter.Router, config conf.Conf, db *database.Queries, signingKey *mjwt.Issuer) {
|
||||
func SetupRouter(r *httprouter.Router, config conf.Conf, mailSender *mail.Mail, db *database.Queries, signingKey *mjwt.Issuer) {
|
||||
// remove last slash from baseUrl
|
||||
config.BaseUrl = strings.TrimRight(config.BaseUrl, "/")
|
||||
|
||||
@ -67,6 +69,7 @@ func SetupRouter(r *httprouter.Router, config conf.Conf, db *database.Queries, s
|
||||
db: db,
|
||||
conf: config,
|
||||
signingKey: signingKey,
|
||||
mailSender: mailSender,
|
||||
|
||||
mailLinkCache: cache.New[mailLinkKey, string](),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user