From a84ac778adf57d6446eef6577e617a80d4c6bb8e Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 19 Jul 2022 15:39:49 +0200 Subject: Ease packaging by making resource path configurable --- invite.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'invite.go') diff --git a/invite.go b/invite.go index 689c7e4..2d01e44 100644 --- a/invite.go +++ b/invite.go @@ -60,7 +60,7 @@ func handleInvitationCode(w http.ResponseWriter, r *http.Request) { inviteDn := config.InvitationNameAttr + "=" + code_id + "," + config.InvitationBaseDN err := l.Bind(inviteDn, code_pw) if err != nil { - templateInviteInvalidCode := template.Must(template.ParseFiles("templates/layout.html", "templates/invite_invalid_code.html")) + templateInviteInvalidCode := template.Must(template.ParseFiles(config.Resources[0]+"/templates/layout.html", config.Resources[0]+"/templates/invite_invalid_code.html")) templateInviteInvalidCode.Execute(w, nil) return } @@ -110,7 +110,7 @@ type NewAccountData struct { } func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invitedBy string) bool { - templateInviteNewAccount := template.Must(template.ParseFiles("templates/layout.html", "templates/invite_new_account.html")) + templateInviteNewAccount := template.Must(template.ParseFiles(config.Resources[0]+"/templates/layout.html", config.Resources[0]+"/templates/invite_new_account.html")) data := &NewAccountData{} @@ -239,7 +239,7 @@ type CodeMailFields struct { } func handleInviteSendCode(w http.ResponseWriter, r *http.Request) { - templateInviteSendCode := template.Must(template.ParseFiles("templates/layout.html", "templates/invite_send_code.html")) + templateInviteSendCode := template.Must(template.ParseFiles(config.Resources[0]+"/templates/layout.html", config.Resources[0]+"/templates/invite_send_code.html")) login := checkInviterLogin(w, r) if login == nil { @@ -298,7 +298,7 @@ func trySendCode(login *LoginStatus, choice string, sendto string, data *SendCod return } - templateMail := template.Must(template.ParseFiles("templates/invite_mail.txt")) + templateMail := template.Must(template.ParseFiles(config.Resources[0]+"/templates/invite_mail.txt")) buf := bytes.NewBuffer([]byte{}) templateMail.Execute(buf, &CodeMailFields{ To: sendto, -- cgit v1.2.3