func cmdResetMfa() { if flagCmdResetMfa { if len(flagEmail) == 0 && len(flagUsername) == 0 { fmt.Fprintln(os.Stderr, "flag needs an argument: -email OR -username") flag.Usage() os.Exit(1) } var user *model.User if len(flagEmail) > 0 { if result := <-api.Srv.Store.User().GetByEmail(flagEmail); result.Err != nil { l4g.Error("%v", result.Err) flushLogAndExit(1) } else { user = result.Data.(*model.User) } } else { if result := <-api.Srv.Store.User().GetByUsername(flagUsername); result.Err != nil { l4g.Error("%v", result.Err) flushLogAndExit(1) } else { user = result.Data.(*model.User) } } if err := api.DeactivateMfa(user.Id); err != nil { l4g.Error("%v", err) flushLogAndExit(1) } os.Exit(0) } }
func resetUserMfaCmdF(cmd *cobra.Command, args []string) error { initDBCommandContextCobra(cmd) if len(args) < 1 { return errors.New("Enter at least one user.") } users := getUsersFromUserArgs(args) for i, user := range users { if user == nil { return errors.New("Unable to find user '" + args[i] + "'") } if err := api.DeactivateMfa(user.Id); err != nil { return err } } return nil }