WebAdmin: allow to pre-select groups on add user page

The admin will still be able to choose different groups

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-09-13 18:04:27 +02:00
parent bd585d8e52
commit ea3c1d7a3b
24 changed files with 1320 additions and 203 deletions

View File

@@ -1636,7 +1636,7 @@ func checkAdmin(expected, actual *dataprovider.Admin) error {
}
}
return nil
return compareAdminGroups(expected, actual)
}
func compareAdminEqualFields(expected *dataprovider.Admin, actual *dataprovider.Admin) error {
@@ -1716,6 +1716,27 @@ func compareUserPermissions(expected map[string][]string, actual map[string][]st
return nil
}
func compareAdminGroups(expected *dataprovider.Admin, actual *dataprovider.Admin) error {
if len(actual.Groups) != len(expected.Groups) {
return errors.New("groups len mismatch")
}
for _, g := range actual.Groups {
found := false
for _, g1 := range expected.Groups {
if g1.Name == g.Name {
found = true
if g1.Options.AddToUsersAs != g.Options.AddToUsersAs {
return fmt.Errorf("add to users as field mismatch for group %s", g.Name)
}
}
}
if !found {
return errors.New("groups mismatch")
}
}
return nil
}
func compareUserGroups(expected *dataprovider.User, actual *dataprovider.User) error {
if len(actual.Groups) != len(expected.Groups) {
return errors.New("groups len mismatch")