diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-04-17 17:06:55 +0200 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-04-17 11:06:55 -0400 |
commit | 51a6e95f58abd65b454e365d45a510eefd84bfe3 (patch) | |
tree | f591a340e446f4b96baf4774957ab43895949811 /cmd/commands/user.go | |
parent | 5511106d93a16626290763e8772b8b562f22100d (diff) | |
download | chat-51a6e95f58abd65b454e365d45a510eefd84bfe3.tar.gz chat-51a6e95f58abd65b454e365d45a510eefd84bfe3.tar.bz2 chat-51a6e95f58abd65b454e365d45a510eefd84bfe3.zip |
add app shutdown to make sure the goroutines finish and all process are closed (#8629)
* run the send email verification as goroutine as well
* add app shutdown to make sure all go routines finish
Diffstat (limited to 'cmd/commands/user.go')
-rw-r--r-- | cmd/commands/user.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/cmd/commands/user.go b/cmd/commands/user.go index 9f5e5ae0d..96e8698e5 100644 --- a/cmd/commands/user.go +++ b/cmd/commands/user.go @@ -254,12 +254,14 @@ func userActivateCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 1 { return errors.New("Expected at least one argument. See help text for details.") } changeUsersActiveStatus(a, args, true) + return nil } @@ -293,12 +295,14 @@ func userDeactivateCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 1 { return errors.New("Expected at least one argument. See help text for details.") } changeUsersActiveStatus(a, args, false) + return nil } @@ -307,6 +311,7 @@ func userCreateCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() username, erru := command.Flags().GetString("username") if erru != nil || username == "" { @@ -352,6 +357,7 @@ func userInviteCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 2 { return errors.New("Expected at least two arguments. See help text for details.") @@ -391,6 +397,7 @@ func resetUserPasswordCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) != 2 { return errors.New("Expected two arguments. See help text for details.") @@ -414,6 +421,7 @@ func updateUserEmailCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() newEmail := args[1] @@ -432,7 +440,7 @@ func updateUserEmailCmdF(command *cobra.Command, args []string) error { user.Email = newEmail _, errUpdate := a.UpdateUser(user, true) - if err != nil { + if errUpdate != nil { return errUpdate } @@ -444,6 +452,7 @@ func resetUserMfaCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 1 { return errors.New("Expected at least one argument. See help text for details.") @@ -469,6 +478,7 @@ func deleteUserCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 1 { return errors.New("Expected at least one argument. See help text for details.") @@ -510,6 +520,7 @@ func deleteAllUsersCommandF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) > 0 { return errors.New("Expected zero arguments.") @@ -536,6 +547,7 @@ func deleteAllUsersCommandF(command *cobra.Command, args []string) error { } cmd.CommandPrettyPrintln("All user accounts successfully deleted.") + return nil } @@ -551,6 +563,7 @@ func migrateAuthToLdapCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() fromAuth := args[0] matchField := args[2] @@ -587,6 +600,7 @@ func migrateAuthToSamlCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() dryRunFlag, _ := command.Flags().GetBool("dryRun") autoFlag, _ := command.Flags().GetBool("auto") @@ -642,6 +656,7 @@ func verifyUserCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 1 { return errors.New("Expected at least one argument. See help text for details.") @@ -667,6 +682,7 @@ func searchUserCmdF(command *cobra.Command, args []string) error { if err != nil { return err } + defer a.Shutdown() if len(args) < 1 { return errors.New("Expected at least one argument. See help text for details.") |