mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
feat: fix potential bugs in init_data.go (#2932)
* fix: fix potential bugs in init data * fix: improve code format
This commit is contained in:
@ -154,6 +154,15 @@ func AddGroups(groups []*Group) (bool, error) {
|
||||
return affected != 0, nil
|
||||
}
|
||||
|
||||
func deleteGroup(group *Group) (bool, error) {
|
||||
affected, err := ormer.Engine.ID(core.PK{group.Owner, group.Name}).Delete(&Group{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return affected != 0, nil
|
||||
}
|
||||
|
||||
func DeleteGroup(group *Group) (bool, error) {
|
||||
_, err := ormer.Engine.Get(group)
|
||||
if err != nil {
|
||||
@ -172,12 +181,7 @@ func DeleteGroup(group *Group) (bool, error) {
|
||||
return false, errors.New("group has users")
|
||||
}
|
||||
|
||||
affected, err := ormer.Engine.ID(core.PK{group.Owner, group.Name}).Delete(&Group{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return affected != 0, nil
|
||||
return deleteGroup(group)
|
||||
}
|
||||
|
||||
func checkGroupName(name string) error {
|
||||
|
Reference in New Issue
Block a user