PLT-4332 Position field for Users (#4632)
* Add User.Position field to store & model. * GOFMT * Add Position to user settings. * Unit tests. * Add position to profile popup. * i18n * Fix log message for invalid position. * Add Position field attribute to LDAP config. * Add Position field attribute to SAML config. * Reword empty position message. * Change Position Max Length to 35. * Better invalid position error message. * Add new fields to config.json. * Ensure position is never longer than max when displayed. * Hard limit of 64 chars with soft limit still 35 * Put field with other attributes.
Этот коммит содержится в:
коммит произвёл
enahum
родитель
9735854503
Коммит
8406e854aa
@@ -251,6 +251,7 @@ type LdapSettings struct {
|
||||
UsernameAttribute *string
|
||||
NicknameAttribute *string
|
||||
IdAttribute *string
|
||||
PositionAttribute *string
|
||||
|
||||
// Syncronization
|
||||
SyncIntervalMinutes *int
|
||||
@@ -297,6 +298,7 @@ type SamlSettings struct {
|
||||
UsernameAttribute *string
|
||||
NicknameAttribute *string
|
||||
LocaleAttribute *string
|
||||
PositionAttribute *string
|
||||
|
||||
LoginButtonText *string
|
||||
}
|
||||
@@ -690,6 +692,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.LdapSettings.IdAttribute = ""
|
||||
}
|
||||
|
||||
if o.LdapSettings.PositionAttribute == nil {
|
||||
o.LdapSettings.PositionAttribute = new(string)
|
||||
*o.LdapSettings.PositionAttribute = ""
|
||||
}
|
||||
|
||||
if o.LdapSettings.SyncIntervalMinutes == nil {
|
||||
o.LdapSettings.SyncIntervalMinutes = new(int)
|
||||
*o.LdapSettings.SyncIntervalMinutes = 60
|
||||
@@ -911,6 +918,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.SamlSettings.NicknameAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.PositionAttribute == nil {
|
||||
o.SamlSettings.PositionAttribute = new(string)
|
||||
*o.SamlSettings.PositionAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.LocaleAttribute == nil {
|
||||
o.SamlSettings.LocaleAttribute = new(string)
|
||||
*o.SamlSettings.LocaleAttribute = ""
|
||||
|
||||
@@ -37,6 +37,7 @@ type User struct {
|
||||
Nickname string `json:"nickname"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Position string `json:"position"`
|
||||
Roles string `json:"roles"`
|
||||
AllowMarketing bool `json:"allow_marketing,omitempty"`
|
||||
Props StringMap `json:"props,omitempty"`
|
||||
@@ -78,6 +79,10 @@ func (u *User) IsValid() *AppError {
|
||||
return NewLocAppError("User.IsValid", "model.user.is_valid.nickname.app_error", nil, "user_id="+u.Id)
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(u.Position) > 35 {
|
||||
return NewLocAppError("User.IsValid", "model.user.is_valid.position.app_error", nil, "user_id="+u.Id)
|
||||
}
|
||||
|
||||
if utf8.RuneCountInString(u.FirstName) > 64 {
|
||||
return NewLocAppError("User.IsValid", "model.user.is_valid.first_name.app_error", nil, "user_id="+u.Id)
|
||||
}
|
||||
|
||||
@@ -128,6 +128,17 @@ func TestUserIsValid(t *testing.T) {
|
||||
if err := user.IsValid(); err == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
user.LastName = ""
|
||||
user.Position = ""
|
||||
if err := user.IsValid(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
user.Position = strings.Repeat("01234567890", 20)
|
||||
if err := user.IsValid(); err == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserGetFullName(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user