diff --git a/data/email-templates/changed-password.html b/data/email-templates/changed-password.html new file mode 100644 index 0000000..e9723b0 --- /dev/null +++ b/data/email-templates/changed-password.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + + +
+ + + + + +
+

+ Hi {{.Username}}, +

+ +

+ Your account password has been successfully + changed. If you made this change, you can + safely disregard this email. +

+ +

+ If you did not change your password, please + contact your system administrator + immediately to secure your account. +

+ +

+ Thanks,
+ {{.ServiceName}} +

+
+
+ + diff --git a/src/main/main.go b/src/main/main.go index 280e7b9..8568764 100644 --- a/src/main/main.go +++ b/src/main/main.go @@ -197,6 +197,17 @@ func changePasswordHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte(`{"success": true}`)) + + data := map[string]any{ + "Username": userData[sessionData.UserID].DisplayName, + "ServiceName": "Astral Tech", + } + + email_template, err := email.RenderTemplate("./data/email-templates/changed-password.html", data, nil) + if err != nil { + logging.Errorf("Failed to load email template: %s", err.Error()) + } + noReplyEmail.SendEmail([]string{userData[sessionData.UserID].Email}, "Password expired", email_template) } func main() {