diff --git a/i18n/en.json b/i18n/en.json index 83beff324b..9ec9f393de 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -2779,6 +2779,10 @@ "id": "model.config.is_valid.saml_username_attribute.app_error", "translation": "Invalid Username attribute. Must be set." }, + { + "id": "model.config.is_valid.sitename_length.app_error", + "translation": "Site name must be less than or equal to {{.MaxLength}} characters." + }, { "id": "model.config.is_valid.sql_data_src.app_error", "translation": "Invalid data source for SQL settings. Must be set." diff --git a/model/config.go b/model/config.go index 8e93200087..64396b65e3 100644 --- a/model/config.go +++ b/model/config.go @@ -44,6 +44,8 @@ const ( RESTRICT_EMOJI_CREATION_ALL = "all" RESTRICT_EMOJI_CREATION_ADMIN = "admin" RESTRICT_EMOJI_CREATION_SYSTEM_ADMIN = "system_admin" + + SITENAME_MAX_LENGTH = 30 ) type ServiceSettings struct { @@ -960,6 +962,10 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PASSWORD_MINIMUM_LENGTH, "MaxLength": PASSWORD_MAXIMUM_LENGTH}, "") } + if len(o.TeamSettings.SiteName) > SITENAME_MAX_LENGTH { + return NewLocAppError("Config.IsValid", "model.config.is_valid.sitename_length.app_error", map[string]interface{}{"MaxLength": SITENAME_MAX_LENGTH}, "") + } + return nil } diff --git a/webapp/components/admin_console/custom_brand_settings.jsx b/webapp/components/admin_console/custom_brand_settings.jsx index 193889ea94..b4026c4a9e 100644 --- a/webapp/components/admin_console/custom_brand_settings.jsx +++ b/webapp/components/admin_console/custom_brand_settings.jsx @@ -11,6 +11,7 @@ import BrandImageSetting from './brand_image_setting.jsx'; import {FormattedMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; +import Constants from 'utils/constants.jsx'; export default class CustomBrandSettings extends AdminSettings { constructor(props) { @@ -115,6 +116,7 @@ export default class CustomBrandSettings extends AdminSettings { defaultMessage='Site Name:' /> } + maxLength={Constants.MAX_SITENAME_LENGTH} placeholder={Utils.localizeMessage('admin.team.siteNameExample', 'Ex "Mattermost"')} helpText={ diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 52fb23d512..df9cb3ba4a 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -761,6 +761,8 @@ export default { MAX_PASSWORD_LENGTH: 64, MIN_TRIGGER_LENGTH: 1, MAX_TRIGGER_LENGTH: 128, + MAX_TEXTSETTING_LENGTH: 1024, + MAX_SITENAME_LENGTH: 30, TIME_SINCE_UPDATE_INTERVAL: 30000, MIN_HASHTAG_LINK_LENGTH: 3, CHANNEL_SCROLL_ADJUSTMENT: 100,