fixed up password reminder E-mail generation (and E-mail generation in general)
This commit is contained in:
@@ -47,6 +47,7 @@ func (*AmCLI) Version() string {
|
||||
// AmConfig holds the configuration of the application as read from YAML.
|
||||
type AmConfig struct {
|
||||
Site struct {
|
||||
BaseURL string `yaml:"baseURL"`
|
||||
Title string `yaml:"title"`
|
||||
TopRefresh int `yaml:"topRefresh"`
|
||||
LoginCookieName string `yaml:"loginCookieName"`
|
||||
@@ -129,6 +130,7 @@ func overlayInt(loaded int, defaulted int) int {
|
||||
* defaults - Points to the default configuration structure.
|
||||
*/
|
||||
func overlayConfig(dest *AmConfig, loaded *AmConfig, defaults *AmConfig) {
|
||||
dest.Site.BaseURL = overlayString(loaded.Site.BaseURL, defaults.Site.BaseURL)
|
||||
dest.Site.Title = overlayString(loaded.Site.Title, defaults.Site.Title)
|
||||
dest.Site.TopRefresh = overlayInt(loaded.Site.TopRefresh, defaults.Site.TopRefresh)
|
||||
dest.Site.LoginCookieName = overlayString(loaded.Site.LoginCookieName, defaults.Site.LoginCookieName)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
site:
|
||||
baseURL: "http://localhost:1323"
|
||||
title: "Amsterdam Web Communities System"
|
||||
topRefresh: 300
|
||||
loginCookieName: AmsterdamAuth
|
||||
|
||||
@@ -24,7 +24,7 @@ type ContactInfo struct {
|
||||
ContactId int32 `db:"contactid"`
|
||||
GivenName string `db:"given_name"`
|
||||
FamilyName string `db:"family_name"`
|
||||
MiddleInit string `db:"middle_init"`
|
||||
MiddleInit *string `db:"middle_init"`
|
||||
Prefix *string `db:"prefix"`
|
||||
Suffix *string `db:"suffix"`
|
||||
Company *string `db:"company"`
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ func AmNewEmailMessage(sender int32, ip string) Message {
|
||||
rc := freeMessages.Get()
|
||||
if rc == nil {
|
||||
rc = &amMessage{to: make([]string, 0), cc: make([]string, 0), bcc: make([]string, 0),
|
||||
headers: make(map[string]string)}
|
||||
headers: make(map[string]string), vars: make(jet.VarMap)}
|
||||
}
|
||||
rc.uid = sender
|
||||
rc.ip = ip
|
||||
|
||||
+13
-4
@@ -68,16 +68,22 @@ func formatMessage(m *amMessage) ([]byte, error) {
|
||||
hdrs := make(map[string]string)
|
||||
maps.Copy(hdrs, m.headers)
|
||||
hdrs["From"] = m.from
|
||||
hdrs["To"] = strings.Join(m.to, ", ")
|
||||
hdrs["Cc"] = strings.Join(m.cc, ", ")
|
||||
hdrs["Bcc"] = strings.Join(m.bcc, ", ")
|
||||
if len(m.to) > 0 {
|
||||
hdrs["To"] = strings.Join(m.to, ", ")
|
||||
}
|
||||
if len(m.cc) > 0 {
|
||||
hdrs["Cc"] = strings.Join(m.cc, ", ")
|
||||
}
|
||||
if len(m.bcc) > 0 {
|
||||
hdrs["Bcc"] = strings.Join(m.bcc, ", ")
|
||||
}
|
||||
hdrs["Subject"] = m.subject
|
||||
hdrs["Content-Type"] = "text/plain; charset=UTF-8"
|
||||
me, _ := os.Hostname()
|
||||
hdrs["X-Amsterdam-Server-Info"] = fmt.Sprintf("%s (Amsterdam/%s)", me, config.AMSTERDAM_VERSION)
|
||||
hdrs["X-Amsterdam-Sender-Info"] = fmt.Sprintf("uid %d, name %s, ip [%s]", m.uid, user.Username, m.ip)
|
||||
for i, v := range disclaimerLines {
|
||||
hdrs[fmt.Sprintf("X-Disclaimer-%d", i)] = v
|
||||
hdrs[fmt.Sprintf("X-Disclaimer-%d", i+1)] = v
|
||||
}
|
||||
|
||||
// Sort the header keys tro make for a better presentation.
|
||||
@@ -208,6 +214,9 @@ func SetupMailSender() func() {
|
||||
embedfs.NewLoader("templates/", emailTemplates),
|
||||
jet.DevelopmentMode(true),
|
||||
)
|
||||
emailRenderer.AddGlobal("AmsterdamVersion", config.AMSTERDAM_VERSION)
|
||||
emailRenderer.AddGlobal("AmsterdamCopyright", config.AMSTERDAM_COPYRIGHT)
|
||||
emailRenderer.AddGlobal("GlobalConfig", config.GlobalConfig)
|
||||
|
||||
// Start the recycler.
|
||||
messageRecycleBin = make(chan *amMessage, 16)
|
||||
|
||||
@@ -7,7 +7,7 @@ If this reminder is not sufficient for you to remember what your password is,
|
||||
then the system can change your password for you. To do so, please visit
|
||||
the following URL:
|
||||
|
||||
http://example.com/passrecovery/{{ change_uid }}/{{ change_auth }}
|
||||
{{ GlobalConfig.Site.BaseURL }}/passrecovery/{{ change_uid }}/{{ change_auth }}
|
||||
|
||||
Your password will be changed and a new password will be E-mailed to you
|
||||
at this address.
|
||||
|
||||
@@ -369,10 +369,11 @@ func NewAccount(ctxt ui.AmContext) (string, any, error) {
|
||||
ci := database.AmNewUserContactInfo(user.Uid)
|
||||
ci.Prefix = dlg.Field("prefix").ValPtr()
|
||||
ci.GivenName = dlg.Field("first").Value
|
||||
ci.MiddleInit = dlg.Field("mid").Value
|
||||
if ci.MiddleInit == "" {
|
||||
ci.MiddleInit = " "
|
||||
mid := dlg.Field("mid").Value
|
||||
if mid == "" {
|
||||
mid = " "
|
||||
}
|
||||
ci.MiddleInit = &mid
|
||||
ci.FamilyName = dlg.Field("last").Value
|
||||
ci.Suffix = dlg.Field("suffix").ValPtr()
|
||||
ci.Locality = dlg.Field("loc").ValPtr()
|
||||
|
||||
Reference in New Issue
Block a user