diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-08-02 16:37:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-02 16:37:09 -0400 |
commit | c4a3118e9f885e92bb9b7d882898e9a51fc3be69 (patch) | |
tree | 7564e7aa04e7c656781b34375d6964d029755c38 /model | |
parent | e67bbcb0ae483cc86ae3a80ace36f1e6e663b589 (diff) | |
download | chat-c4a3118e9f885e92bb9b7d882898e9a51fc3be69.tar.gz chat-c4a3118e9f885e92bb9b7d882898e9a51fc3be69.tar.bz2 chat-c4a3118e9f885e92bb9b7d882898e9a51fc3be69.zip |
PLT-3408 Add SiteURL to config.json (#3692)
* PLT-3408 Changed serverside code to get the service's URL from config.json
* PLT-3408 Changed most clientside code to use the SiteURL config setting instead of window.location
* PLT-3408 Changed default SiteURL to be autodetected
Diffstat (limited to 'model')
-rw-r--r-- | model/config.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go index 85b71cb2a..b239c83ca 100644 --- a/model/config.go +++ b/model/config.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "net/url" ) const ( @@ -50,6 +51,7 @@ const ( ) type ServiceSettings struct { + SiteURL *string ListenAddress string MaximumLoginAttempts int SegmentDeveloperKey string @@ -363,6 +365,11 @@ func (o *Config) SetDefaults() { o.EmailSettings.PasswordResetSalt = NewRandomString(32) } + if o.ServiceSettings.SiteURL == nil { + o.ServiceSettings.SiteURL = new(string) + *o.ServiceSettings.SiteURL = "" + } + if o.ServiceSettings.EnableDeveloper == nil { o.ServiceSettings.EnableDeveloper = new(bool) *o.ServiceSettings.EnableDeveloper = false @@ -832,6 +839,16 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.login_attempts.app_error", nil, "") } + if len(*o.ServiceSettings.SiteURL) != 0 { + if _, err := url.ParseRequestURI(*o.ServiceSettings.SiteURL); err != nil { + return NewLocAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, "") + } + } + + if len(o.ServiceSettings.ListenAddress) == 0 { + return NewLocAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "") + } + if len(o.ServiceSettings.ListenAddress) == 0 { return NewLocAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "") } |