[#7314] added ALERT_INFO placeholder to the auth alert mail template

This commit is contained in:
Gani Georgiev
2025-11-10 17:56:36 +02:00
parent 423d234da1
commit 0f5411d81c
40 changed files with 137 additions and 60 deletions
+4 -2
View File
@@ -12,10 +12,12 @@ import (
)
// SendRecordAuthAlert sends a new device login alert to the specified auth record.
func SendRecordAuthAlert(app core.App, authRecord *core.Record) error {
func SendRecordAuthAlert(app core.App, authRecord *core.Record, info string) error {
mailClient := app.NewMailClient()
subject, body, err := resolveEmailTemplate(app, authRecord, authRecord.Collection().AuthAlert.EmailTemplate, nil)
subject, body, err := resolveEmailTemplate(app, authRecord, authRecord.Collection().AuthAlert.EmailTemplate, map[string]any{
core.EmailPlaceholderAlertInfo: info,
})
if err != nil {
return err
}
+2 -1
View File
@@ -20,7 +20,7 @@ func TestSendRecordAuthAlert(t *testing.T) {
// to test that it is escaped
user.Set("name", "<p>"+user.GetString("name")+"</p>")
err := mails.SendRecordAuthAlert(testApp, user)
err := mails.SendRecordAuthAlert(testApp, user, "test_info")
if err != nil {
t.Fatal(err)
}
@@ -34,6 +34,7 @@ func TestSendRecordAuthAlert(t *testing.T) {
"login to your " + testApp.Settings().Meta.AppName + " account from a new location",
"If this was you",
"If this wasn't you",
"test_info",
}
for _, part := range expectedParts {
if !strings.Contains(testApp.TestMailer.LastMessage().HTML, part) {