forked from tildetown/town
make use of IsAdmin
parent
362ca0fa19
commit
a92c972d43
|
@ -9,6 +9,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
townuser "git.tilde.town/tildetown/town/user"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
@ -30,24 +31,7 @@ func isAdmin() (bool, error) {
|
|||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get information about current user: %w", err)
|
||||
}
|
||||
|
||||
adminGroup, err := user.LookupGroup("admin")
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get admin group info: %w", err)
|
||||
}
|
||||
|
||||
groupIds, err := u.GroupIds()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get groups info: %w", err)
|
||||
}
|
||||
|
||||
for _, groupId := range groupIds {
|
||||
if groupId == adminGroup.Gid {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
return townuser.IsAdmin(u)
|
||||
}
|
||||
|
||||
func parseCommands(targetCmd *cobra.Command, path string) error {
|
||||
|
|
Loading…
Reference in New Issue