mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user