From 11cbb597471127c1b29e78e6cad0a1a4d93ea24c Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 17 May 2018 12:40:40 -0700 Subject: Renaming platform binary to mattermost. (#8801) --- cmd/commands/roles.go | 90 --------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 cmd/commands/roles.go (limited to 'cmd/commands/roles.go') diff --git a/cmd/commands/roles.go b/cmd/commands/roles.go deleted file mode 100644 index 6d832d82a..000000000 --- a/cmd/commands/roles.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -package commands - -import ( - "errors" - - "github.com/mattermost/mattermost-server/cmd" - "github.com/spf13/cobra" -) - -var RolesCmd = &cobra.Command{ - Use: "roles", - Short: "Management of user roles", -} - -var MakeSystemAdminCmd = &cobra.Command{ - Use: "system_admin [users]", - Short: "Set a user as system admin", - Long: "Make some users system admins", - Example: " roles system_admin user1", - RunE: makeSystemAdminCmdF, -} - -var MakeMemberCmd = &cobra.Command{ - Use: "member [users]", - Short: "Remove system admin privileges", - Long: "Remove system admin privileges from some users.", - Example: " roles member user1", - RunE: makeMemberCmdF, -} - -func init() { - RolesCmd.AddCommand( - MakeSystemAdminCmd, - MakeMemberCmd, - ) - cmd.RootCmd.AddCommand(RolesCmd) -} - -func makeSystemAdminCmdF(command *cobra.Command, args []string) error { - a, err := cmd.InitDBCommandContextCobra(command) - if err != nil { - return err - } - defer a.Shutdown() - - if len(args) < 1 { - return errors.New("Enter at least one user.") - } - - users := getUsersFromUserArgs(a, args) - for i, user := range users { - if user == nil { - return errors.New("Unable to find user '" + args[i] + "'") - } - - if _, err := a.UpdateUserRoles(user.Id, "system_admin system_user", true); err != nil { - return err - } - } - - return nil -} - -func makeMemberCmdF(command *cobra.Command, args []string) error { - a, err := cmd.InitDBCommandContextCobra(command) - if err != nil { - return err - } - defer a.Shutdown() - - if len(args) < 1 { - return errors.New("Enter at least one user.") - } - - users := getUsersFromUserArgs(a, args) - for i, user := range users { - if user == nil { - return errors.New("Unable to find user '" + args[i] + "'") - } - - if _, err := a.UpdateUserRoles(user.Id, "system_user", true); err != nil { - return err - } - } - - return nil -} -- cgit v1.2.3-1-g7c22