chore: extract mail to it's own service
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 45s

This commit is contained in:
2024-09-27 23:21:37 +02:00
parent ee273ed484
commit ec0e748e1f
7 changed files with 117 additions and 53 deletions

View File

@@ -49,11 +49,13 @@ type ServiceAuth interface {
type ServiceAuthImpl struct {
dbAuth db.DbAuth
mail ServiceMail
}
func NewServiceAuthImpl(dbAuth db.DbAuth) *ServiceAuthImpl {
func NewServiceAuthImpl(dbAuth db.DbAuth, mail ServiceMail) *ServiceAuthImpl {
return &ServiceAuthImpl{
dbAuth: dbAuth,
mail: mail,
}
}
@@ -399,7 +401,8 @@ func HandleDeleteAccountComp(db *sql.DB) http.HandlerFunc {
return
}
go utils.SendMail(user.Email, "Account deleted", "Your account has been deleted")
//TODO
// go utils.SendMail(user.Email, "Account deleted", "Your account has been deleted")
utils.DoRedirect(w, r, "/")
}
@@ -577,7 +580,8 @@ func HandleResetPasswordComp(db *sql.DB) http.HandlerFunc {
utils.TriggerToast(w, r, "error", "Internal Server Error")
return
}
utils.SendMail(email, "Reset Password", mail.String())
//TODO
// utils.SendMail(email, "Reset Password", mail.String())
}
utils.TriggerToast(w, r, "info", "If the email exists, an email has been sent")
@@ -612,7 +616,8 @@ func sendVerificationEmail(db *sql.DB, userId string, email string) {
utils.LogError("Could not render welcome email", err)
return
}
utils.SendMail(email, "Welcome to ME-FIT", w.String())
//TODO
// utils.SendMail(email, "Welcome to ME-FIT", w.String())
}
func TryCreateSessionAndSetCookie(r *http.Request, w http.ResponseWriter, db *sql.DB, user_uuid uuid.UUID) error {