коммит произвёл
GitHub
родитель
4aac52bced
Коммит
6a77e24adc
31
app/user.go
31
app/user.go
@@ -1183,6 +1183,37 @@ func (a *App) UpdateUserAsUser(user *model.User, asAdmin bool) (*model.User, *mo
|
||||
return updatedUser, nil
|
||||
}
|
||||
|
||||
// CheckProviderAttributes returns the empty string if the patch can be applied without
|
||||
// overriding attributes set by the user's login provider; otherwise, the name of the offending
|
||||
// field is returned.
|
||||
func (a *App) CheckProviderAttributes(user *model.User, patch *model.UserPatch) string {
|
||||
tryingToChange := func(userValue *string, patchValue *string) bool {
|
||||
return patchValue != nil && *patchValue != *userValue
|
||||
}
|
||||
|
||||
// If any login provider is used, then the username may not be changed
|
||||
if user.AuthService != "" && tryingToChange(&user.Username, patch.Username) {
|
||||
return "username"
|
||||
}
|
||||
|
||||
LdapSettings := &a.Config().LdapSettings
|
||||
SamlSettings := &a.Config().SamlSettings
|
||||
|
||||
conflictField := ""
|
||||
if a.Ldap() != nil &&
|
||||
(user.IsLDAPUser() || (user.IsSAMLUser() && *SamlSettings.EnableSyncWithLdap)) {
|
||||
conflictField = a.Ldap().CheckProviderAttributes(LdapSettings, user, patch)
|
||||
} else if a.Saml() != nil && user.IsSAMLUser() {
|
||||
conflictField = a.Saml().CheckProviderAttributes(SamlSettings, user, patch)
|
||||
} else if user.IsOAuthUser() {
|
||||
if tryingToChange(&user.FirstName, patch.FirstName) || tryingToChange(&user.LastName, patch.LastName) {
|
||||
conflictField = "full name"
|
||||
}
|
||||
}
|
||||
|
||||
return conflictField
|
||||
}
|
||||
|
||||
func (a *App) PatchUser(userID string, patch *model.UserPatch, asAdmin bool) (*model.User, *model.AppError) {
|
||||
user, err := a.GetUser(userID)
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user