diff options
-rw-r--r-- | i18n/en.json | 4 | ||||
-rw-r--r-- | mattermost.go | 4 | ||||
-rw-r--r-- | model/config.go | 19 | ||||
-rw-r--r-- | utils/config.go | 6 |
4 files changed, 27 insertions, 6 deletions
diff --git a/i18n/en.json b/i18n/en.json index b6c9e91cc..e428dc781 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -2516,6 +2516,10 @@ "translation": "Invalid sync interval time. Must be at least one minute." }, { + "id": "model.config.is_valid.ldap_required.app_error", + "translation": "Required LDAP field missing." + }, + { "id": "model.config.is_valid.listen_address.app_error", "translation": "Invalid listen address for service settings Must be set." }, diff --git a/mattermost.go b/mattermost.go index 963978ecf..bdfa55d9a 100644 --- a/mattermost.go +++ b/mattermost.go @@ -71,7 +71,7 @@ var flagRunCmds bool func doLoadConfig(filename string) (err string) { defer func() { if r := recover(); r != nil { - err = fmt.Sprintf("Error loding config, err=%v", r) + err = fmt.Sprintf("%v", r) } }() utils.LoadConfig(filename) @@ -83,7 +83,7 @@ func main() { parseCmds() if errstr := doLoadConfig(flagConfigFile); errstr != "" { - l4g.Exit("Unable to load mattermost configuration file:", errstr) + l4g.Exit("Unable to load mattermost configuration file: ", errstr) return } diff --git a/model/config.go b/model/config.go index cbb254768..51a3b252e 100644 --- a/model/config.go +++ b/model/config.go @@ -486,6 +486,11 @@ func (o *Config) SetDefaults() { *o.LdapSettings.EmailAttribute = "" } + if o.LdapSettings.UsernameAttribute == nil { + o.LdapSettings.UsernameAttribute = new(string) + *o.LdapSettings.UsernameAttribute = "" + } + if o.LdapSettings.NicknameAttribute == nil { o.LdapSettings.NicknameAttribute = new(string) *o.LdapSettings.NicknameAttribute = "" @@ -709,6 +714,20 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "") } + if *o.LdapSettings.Enable { + if *o.LdapSettings.LdapServer == "" || + *o.LdapSettings.BaseDN == "" || + *o.LdapSettings.BindUsername == "" || + *o.LdapSettings.BindPassword == "" || + *o.LdapSettings.FirstNameAttribute == "" || + *o.LdapSettings.LastNameAttribute == "" || + *o.LdapSettings.EmailAttribute == "" || + *o.LdapSettings.UsernameAttribute == "" || + *o.LdapSettings.IdAttribute == "" { + return NewLocAppError("Config.IsValid", "Required LDAP field missing", nil, "") + } + } + return nil } diff --git a/utils/config.go b/utils/config.go index 5b8ba0906..79d1d8e4b 100644 --- a/utils/config.go +++ b/utils/config.go @@ -168,13 +168,11 @@ func LoadConfig(fileName string) { config.SetDefaults() if err := config.IsValid(); err != nil { - panic(T("utils.config.load_config.validating.panic", - map[string]interface{}{"Filename": fileName, "Error": err.Message})) + panic(err.Error()) } if err := ValidateLdapFilter(&config); err != nil { - panic(T("utils.config.load_config.validating.panic", - map[string]interface{}{"Filename": fileName, "Error": err.Message})) + panic(err.Error()) } configureLog(&config.LogSettings) |