diff --git a/internal/admin.go b/internal/admin.go index e170e5a..ea87bee 100644 --- a/internal/admin.go +++ b/internal/admin.go @@ -233,7 +233,7 @@ func (a *Application) HandleAdminLogin(w http.ResponseWriter, r *http.Request) { } else { log.Info().Msg("sent email") http.SetCookie(w, &http.Cookie{Name: "admin_email", Value: emailAddress, Path: "/"}) - a.ConfirmEmailRenderer(w, r, map[string]any{"Email": emailAddress}) + a.AdminConfirmEmailRenderer(w, r, map[string]any{"Email": emailAddress}) } } diff --git a/internal/application.go b/internal/application.go index c26c052..40b4872 100644 --- a/internal/application.go +++ b/internal/application.go @@ -23,11 +23,13 @@ type Application struct { EmailRegex *regexp.Regexp Config config.Configuration - ConfirmEmailRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) - TeacherLoginRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) - EmailLoginRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) - StudentConfirmInfoRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) - TeamAddMemberRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + ConfirmEmailRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + VolunteerConfirmEmailRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + AdminConfirmEmailRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + TeacherLoginRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + EmailLoginRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + StudentConfirmInfoRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) + TeamAddMemberRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) TeacherCreateAccountRenderer func(w http.ResponseWriter, r *http.Request, extraData map[string]any) @@ -139,6 +141,9 @@ func (a *Application) Start() { a.TeacherLoginRenderer = a.ServeTemplateExtra(a.Log, "teacherlogin.html", a.GetEmailLoginTemplate) a.TeacherCreateAccountRenderer = a.ServeTemplateExtra(a.Log, "teachercreateaccount.html", a.GetTeacherCreateAccountTemplate) a.ConfirmEmailRenderer = a.ServeTemplateExtra(a.Log, "confirmemail.html", a.GetEmailLoginTemplate) + a.VolunteerConfirmEmailRenderer = a.ServeTemplateExtra(a.Log, "volunteerconfirmemail.html", a.GetEmailLoginTemplate) + a.AdminConfirmEmailRenderer = a.ServeTemplateExtra(a.Log, "adminconfirmemail.html", a.GetEmailLoginTemplate) + a.EmailLoginRenderer = a.ServeTemplateExtra(a.Log, "emaillogin.html", a.GetEmailLoginTemplate) a.StudentConfirmInfoRenderer = a.ServeTemplateExtra(a.Log, "student.html", a.GetStudentConfirmInfoTemplate) a.TeamAddMemberRenderer = a.ServeTemplateExtra(a.Log, "teamaddmember.html", a.GetTeacherAddMemberTemplate) @@ -156,6 +161,10 @@ func (a *Application) Start() { // Parent "/register/parent/signforms": {a.ServeTemplateExtra(a.Log, "parent.html", a.GetParentSignFormsTemplate), false}, + + // Admin & Volunteer + "/register/volunteer/confirmemail": {a.VolunteerConfirmEmailRenderer, true}, + "/register/admin/confirmemail": {a.AdminConfirmEmailRenderer, true}, } for path, rend := range registrationPages { renderFn := func(path string, rend renderInfo) func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/volunteer.go b/internal/volunteer.go index 345af1b..dd4da77 100644 --- a/internal/volunteer.go +++ b/internal/volunteer.go @@ -115,7 +115,7 @@ func (a *Application) HandleVolunteerLogin(w http.ResponseWriter, r *http.Reques } else { log.Info().Msg("sent email") http.SetCookie(w, &http.Cookie{Name: "volunteer_email", Value: emailAddress, Path: "/"}) - a.ConfirmEmailRenderer(w, r, map[string]any{"Email": emailAddress}) + a.VolunteerConfirmEmailRenderer(w, r, map[string]any{"Email": emailAddress}) } } diff --git a/website/templates/adminconfirmemail.html b/website/templates/adminconfirmemail.html new file mode 100644 index 0000000..bfe97ce --- /dev/null +++ b/website/templates/adminconfirmemail.html @@ -0,0 +1,37 @@ +{{ define "title" }}Confirm Email{{ end }} + +{{ define "content" }} +
+ +
+ +
+ {{ with .Data.Error }} +
+ +
+ {{ else }} +
+
+

+ We've sent an email to {{ .Data.Email }}. +

+

+

+ Please check your email and click the link to confirm your email address and log in. +

+
+
+ {{ end }} +
+{{ end }} diff --git a/website/templates/volunteerconfirmemail.html b/website/templates/volunteerconfirmemail.html new file mode 100644 index 0000000..e9ae957 --- /dev/null +++ b/website/templates/volunteerconfirmemail.html @@ -0,0 +1,37 @@ +{{ define "title" }}Confirm Email{{ end }} + +{{ define "content" }} +
+ +
+ +
+ {{ with .Data.Error }} +
+ +
+ {{ else }} +
+
+

+ Thanks for volunteering! We've sent an email to {{ .Data.Email }}. +

+

+

+ Please check your email and click the link to confirm your email address and log in. +

+
+
+ {{ end }} +
+{{ end }}