Making LDAP FirstName and LastName fields optional. (#3919)

Этот коммит содержится в:
Christopher Speller
2016-09-01 10:03:55 -04:00
коммит произвёл Joram Wilander
родитель e1e29a86d9
Коммит 276e0189b1
6 изменённых файлов: 9 добавлений и 15 удалений

Просмотреть файл

@@ -1013,14 +1013,6 @@ func (o *Config) IsValid() *AppError {
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "")
}
if *o.LdapSettings.FirstNameAttribute == "" {
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_firstname", nil, "")
}
if *o.LdapSettings.LastNameAttribute == "" {
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_lastname", nil, "")
}
if *o.LdapSettings.EmailAttribute == "" {
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "")
}

Просмотреть файл

@@ -132,8 +132,6 @@ func (us SqlUserStore) Update(user *model.User, trustedUpdateData bool) StoreCha
user.Email = oldUser.Email
} else if user.IsLDAPUser() && !trustedUpdateData {
if user.Username != oldUser.Username ||
user.FirstName != oldUser.FirstName ||
user.LastName != oldUser.LastName ||
user.Email != oldUser.Email {
result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.can_not_change_ldap.app_error", nil, "user_id="+user.Id)
storeChannel <- result

Просмотреть файл

@@ -281,6 +281,8 @@ func getClientConfig(c *model.Config) map[string]string {
props["EnableLdap"] = strconv.FormatBool(*c.LdapSettings.Enable)
props["LdapLoginFieldName"] = *c.LdapSettings.LoginFieldName
props["NicknameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.NicknameAttribute != "")
props["FirstNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.FirstNameAttribute != "")
props["LastNameAttributeSet"] = strconv.FormatBool(*c.LdapSettings.LastNameAttribute != "")
}
if *License.Features.MFA {

Просмотреть файл

@@ -236,7 +236,7 @@ export default class LdapSettings extends AdminSettings {
helpText={
<FormattedMessage
id='admin.ldap.firstnameAttrDesc'
defaultMessage='The attribute in the LDAP server that will be used to populate the first name of users in Mattermost.'
defaultMessage='(Optional) The attribute in the LDAP server that will be used to populate the first name of users in Mattermost.'
/>
}
value={this.state.firstNameAttribute}
@@ -255,7 +255,7 @@ export default class LdapSettings extends AdminSettings {
helpText={
<FormattedMessage
id='admin.ldap.lastnameAttrDesc'
defaultMessage='The attribute in the LDAP server that will be used to populate the last name of users in Mattermost.'
defaultMessage='(Optional) The attribute in the LDAP server that will be used to populate the last name of users in Mattermost.'
/>
}
value={this.state.lastNameAttribute}

Просмотреть файл

@@ -629,7 +629,9 @@ class UserSettingsGeneralTab extends React.Component {
if (this.props.activeSection === 'name') {
let extraInfo;
let submit = null;
if (this.props.user.auth_service === '') {
if (this.props.user.auth_service === '' ||
(this.props.user.auth_service === 'ldap' &&
(global.window.mm_config.FirstNameAttributeSet === 'false' || global.window.mm_config.LastNameAttributeSet === 'false'))) {
inputs.push(
<div
key='firstNameSetting'

Просмотреть файл

@@ -401,13 +401,13 @@
"admin.ldap.emailAttrTitle": "Email Attribute:",
"admin.ldap.enableDesc": "When true, Mattermost allows login using LDAP",
"admin.ldap.enableTitle": "Enable sign-in with LDAP:",
"admin.ldap.firstnameAttrDesc": "The attribute in the LDAP server that will be used to populate the first name of users in Mattermost.",
"admin.ldap.firstnameAttrDesc": "(Optional) The attribute in the LDAP server that will be used to populate the first name of users in Mattermost.",
"admin.ldap.firstnameAttrEx": "Ex \"givenName\"",
"admin.ldap.firstnameAttrTitle": "First Name Attribute",
"admin.ldap.idAttrDesc": "The attribute in the LDAP server that will be used as a unique identifier in Mattermost. It should be an LDAP attribute with a value that does not change, such as username or uid. If a users ID Attribute changes, it will create a new Mattermost account unassociated with their old one. This is the value used to log in to Mattermost in the \"LDAP Username\" field on the sign in page. Normally this attribute is the same as the “Username Attribute” field above. If your team typically uses domain\\username to sign in to other services with LDAP, you may choose to put domain\\username in this field to maintain consistency between sites.",
"admin.ldap.idAttrEx": "Ex \"sAMAccountName\"",
"admin.ldap.idAttrTitle": "ID Attribute: ",
"admin.ldap.lastnameAttrDesc": "The attribute in the LDAP server that will be used to populate the last name of users in Mattermost.",
"admin.ldap.lastnameAttrDesc": "(Optional) The attribute in the LDAP server that will be used to populate the last name of users in Mattermost.",
"admin.ldap.lastnameAttrEx": "Ex \"sn\"",
"admin.ldap.lastnameAttrTitle": "Last Name Attribute:",
"admin.ldap.loginNameDesc": "The placeholder text that appears in the login field on the login page. Defaults to \"LDAP Username\".",