summaryrefslogtreecommitdiffstats
path: root/cmd/mattermost/commands/permissions.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-05-17 12:40:40 -0700
committerGitHub <noreply@github.com>2018-05-17 12:40:40 -0700
commit11cbb597471127c1b29e78e6cad0a1a4d93ea24c (patch)
tree0eceb950872c7234348f0b41d4492073908840d0 /cmd/mattermost/commands/permissions.go
parent1f6c271b3bedd6656ae7155714423b1b39a669c1 (diff)
downloadchat-11cbb597471127c1b29e78e6cad0a1a4d93ea24c.tar.gz
chat-11cbb597471127c1b29e78e6cad0a1a4d93ea24c.tar.bz2
chat-11cbb597471127c1b29e78e6cad0a1a4d93ea24c.zip
Renaming platform binary to mattermost. (#8801)
Diffstat (limited to 'cmd/mattermost/commands/permissions.go')
-rw-r--r--cmd/mattermost/commands/permissions.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/cmd/mattermost/commands/permissions.go b/cmd/mattermost/commands/permissions.go
new file mode 100644
index 000000000..52cae0ecb
--- /dev/null
+++ b/cmd/mattermost/commands/permissions.go
@@ -0,0 +1,64 @@
+// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package commands
+
+import (
+ "errors"
+ "fmt"
+
+ "github.com/spf13/cobra"
+)
+
+var PermissionsCmd = &cobra.Command{
+ Use: "permissions",
+ Short: "Management of the Permissions system",
+}
+
+var ResetPermissionsCmd = &cobra.Command{
+ Use: "reset",
+ Short: "Reset the permissions system to its default state",
+ Long: "Reset the permissions system to its default state",
+ Example: " permissions reset",
+ RunE: resetPermissionsCmdF,
+}
+
+func init() {
+ ResetPermissionsCmd.Flags().Bool("confirm", false, "Confirm you really want to reset the permissions system and a database backup has been performed.")
+
+ PermissionsCmd.AddCommand(
+ ResetPermissionsCmd,
+ )
+ RootCmd.AddCommand(PermissionsCmd)
+}
+
+func resetPermissionsCmdF(command *cobra.Command, args []string) error {
+ a, err := InitDBCommandContextCobra(command)
+ if err != nil {
+ return err
+ }
+
+ confirmFlag, _ := command.Flags().GetBool("confirm")
+ if !confirmFlag {
+ var confirm string
+ CommandPrettyPrintln("Have you performed a database backup? (YES/NO): ")
+ fmt.Scanln(&confirm)
+
+ if confirm != "YES" {
+ return errors.New("ABORTED: You did not answer YES exactly, in all capitals.")
+ }
+ CommandPrettyPrintln("Are you sure you want to reset the permissions system? All data related to the permissions system will be permanently deleted and all users will revert to having the default permissions. (YES/NO): ")
+ fmt.Scanln(&confirm)
+ if confirm != "YES" {
+ return errors.New("ABORTED: You did not answer YES exactly, in all capitals.")
+ }
+ }
+
+ if err := a.ResetPermissionsSystem(); err != nil {
+ return errors.New(err.Error())
+ }
+
+ CommandPrettyPrintln("Permissions system successfully reset")
+
+ return nil
+}