add user templates

This commit is contained in:
stryan 2020-11-12 14:51:48 -05:00
parent 0c347eda8e
commit 0b86f1f4bb
2 changed files with 16 additions and 10 deletions

View File

@ -25,16 +25,17 @@ type MailConfig struct {
} }
type Config struct { type Config struct {
Ldap *LdapConfig Ldap *LdapConfig
Mail *MailConfig Mail *MailConfig
Secret string Secret string
TplPath string TplPath string
Tls bool UserTplPath string
Key string Tls bool
Cert string Key string
Port string Cert string
MaxID int Port string
lock sync.Mutex MaxID int
lock sync.Mutex
} }
func validateConfigEntry(entry string, name string) bool { func validateConfigEntry(entry string, name string) bool {
@ -74,6 +75,7 @@ func LoadConfig() (*Config, error) {
c.Key = viper.GetString("tls_key") c.Key = viper.GetString("tls_key")
c.Cert = viper.GetString("tls_cert") c.Cert = viper.GetString("tls_cert")
c.TplPath = viper.GetString("templates_path") c.TplPath = viper.GetString("templates_path")
c.UserTplPath = viper.GetString("user_templates_path")
m.SmtpServer = viper.GetString("SmtpServer") m.SmtpServer = viper.GetString("SmtpServer")
m.Username = viper.GetString("SmtpUsername") m.Username = viper.GetString("SmtpUsername")
m.Password = viper.GetString("SmtpPassword") m.Password = viper.GetString("SmtpPassword")

View File

@ -41,6 +41,10 @@ func main() {
router.HandleFunc("/reset/error", resetErrorPage).Methods("GET") router.HandleFunc("/reset/error", resetErrorPage).Methods("GET")
log.Printf("Registering templates from %v/\n", Conf.TplPath) log.Printf("Registering templates from %v/\n", Conf.TplPath)
tpl = template.Must(template.ParseGlob(Conf.TplPath + "/*")) tpl = template.Must(template.ParseGlob(Conf.TplPath + "/*"))
if Conf.UserTplPath != "" {
log.Printf("Registering user templates from %v/\n", Conf.UsrTplPath)
tpl = template.Must(tpl.ParseGlob(Conf.UserTplPath + "/*"))
}
log.Println("Performing LDAP checks") log.Println("Performing LDAP checks")
log.Println("Loading max employeeNumber for account creation") log.Println("Loading max employeeNumber for account creation")
i, err := findLDAPMaxID() i, err := findLDAPMaxID()