add preffered language

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2023-11-09 14:30:24 +01:00
parent 5eff669a57
commit d96031b7d3
2 changed files with 20 additions and 13 deletions

View File

@@ -72,14 +72,15 @@ type LDAP struct {
}
type userAttributeMap struct {
displayName string
id string
mail string
userName string
givenName string
surname string
accountEnabled string
userType string
displayName string
id string
mail string
userName string
givenName string
surname string
accountEnabled string
userType string
preferredLanguage string
}
type ldapAttributeValues map[string][]string
@@ -300,11 +301,12 @@ func (i *LDAP) UpdateUser(ctx context.Context, nameOrID string, user libregraph.
mr := ldap.ModifyRequest{DN: e.DN}
properties := map[string]string{
i.userAttributeMap.displayName: user.GetDisplayName(),
i.userAttributeMap.mail: user.GetMail(),
i.userAttributeMap.surname: user.GetSurname(),
i.userAttributeMap.givenName: user.GetGivenName(),
i.userAttributeMap.userType: user.GetUserType(),
i.userAttributeMap.displayName: user.GetDisplayName(),
i.userAttributeMap.mail: user.GetMail(),
i.userAttributeMap.surname: user.GetSurname(),
i.userAttributeMap.givenName: user.GetGivenName(),
i.userAttributeMap.userType: user.GetUserType(),
i.userAttributeMap.preferredLanguage: user.GetPreferredLanguage(),
}
for attribute, value := range properties {
@@ -394,6 +396,7 @@ func (i *LDAP) getUserByDN(dn string) (*ldap.Entry, error) {
i.userAttributeMap.givenName,
i.userAttributeMap.accountEnabled,
i.userAttributeMap.userType,
i.userAttributeMap.preferredLanguage,
}
filter := fmt.Sprintf("(objectClass=%s)", i.userObjectClass)
@@ -521,6 +524,7 @@ func (i *LDAP) getLDAPUserByFilter(filter string) (*ldap.Entry, error) {
i.userAttributeMap.accountEnabled,
i.userAttributeMap.userType,
i.userAttributeMap.preferredLanguage,
}
return i.searchLDAPEntryByFilter(i.userBaseDN, attrs, filter)
}
@@ -600,6 +604,7 @@ func (i *LDAP) GetUsers(ctx context.Context, oreq *godata.GoDataRequest) ([]*lib
i.userAttributeMap.givenName,
i.userAttributeMap.accountEnabled,
i.userAttributeMap.userType,
i.userAttributeMap.preferredLanguage,
},
nil,
)
@@ -856,6 +861,7 @@ func (i *LDAP) getUserAttrTypes() []string {
"userPassword",
i.userAttributeMap.accountEnabled,
i.userAttributeMap.userType,
i.userAttributeMap.preferredLanguage,
}
}

View File

@@ -225,6 +225,7 @@ func NewService(opts ...Option) (Graph, error) {
r.Post("/exportPersonalData", svc.ExportPersonalData)
r.With(requireAdmin).Delete("/", svc.DeleteUser)
r.With(requireAdmin).Patch("/", svc.PatchUser)
r.With(requireAdmin).Patch("/language/{language}", svc.SetUserLanguage)
if svc.roleService != nil {
r.With(requireAdmin).Route("/appRoleAssignments", func(r chi.Router) {
r.Get("/", svc.ListAppRoleAssignments)