Ajout d'un lien de contact/support dans la page de profil

Adresse de contact et sujet par défaut configurable dans le fichier de
configuration
This commit is contained in:
wpetit 2019-05-31 13:46:17 +02:00
parent 898301bf65
commit e62837d7be
3 changed files with 17 additions and 2 deletions

View File

@ -7,8 +7,9 @@ import (
)
type Config struct {
HTTP HTTPConfig
LDAP LDAPConfig
HTTP HTTPConfig
LDAP LDAPConfig
Contact ContactConfig
}
type HTTPConfig struct {
@ -23,6 +24,11 @@ type LDAPConfig struct {
UserSearchFilterPattern string
}
type ContactConfig struct {
Email string
Subject string
}
// NewFromFile retrieves the configuration from the given file
func NewFromFile(filepath string) (*Config, error) {
config := NewDefault()
@ -48,6 +54,10 @@ func NewDefault() *Config {
BaseDN: "o=org,c=fr",
UserSearchFilterPattern: "(&(objectClass=person)(uid=%s))",
},
Contact: ContactConfig{
Email: "contact@cadoles-profile.local",
Subject: "[Cadoles Profile] Help needed",
},
}
}

View File

@ -196,10 +196,12 @@ func serveProfilePage(w http.ResponseWriter, r *http.Request) {
}
tmpl := template.Must(ctn)
config := config.Must(ctn)
data := extendTemplateData(w, r, template.Data{
"EntryAttributes": results.Entries[0].Attributes,
csrf.TemplateTag: csrf.TemplateField(r),
"Contact": config.Contact,
})
if err := tmpl.RenderPage(w, "profile.html.tmpl", data); err != nil {

View File

@ -49,6 +49,9 @@
</form>
</div>
</div>
<p class="has-margin-top-small has-text-centered">
<strong>Une question, un problème ?</strong> <a href="mailto:{{ .Contact.Email }}?subject={{ .Contact.Subject }}">Contacter le support</a>
</p>
</div>
</div>
</div>