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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e67bbcb0ae
Коммит
c4a3118e9f
@@ -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, "")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user