forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword_reset.go
47 lines (38 loc) · 894 Bytes
/
password_reset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cmd
import (
"github.com/AlecAivazis/survey/v2"
"github.com/evcc-io/evcc/util/auth"
"github.com/spf13/cobra"
)
var passwordResetCmd = &cobra.Command{
Use: "reset",
Short: "Reset password",
Args: cobra.ExactArgs(0),
Run: runPasswordReset,
}
func init() {
passwordCmd.AddCommand(passwordResetCmd)
}
func runPasswordReset(cmd *cobra.Command, args []string) {
// load config
if err := loadConfigFile(&conf, !cmd.Flag(flagIgnoreDatabase).Changed); err != nil {
log.FATAL.Fatal(err)
}
// setup environment
if err := configureEnvironment(cmd, &conf); err != nil {
log.FATAL.Fatal(err)
}
prompt := &survey.Confirm{
Message: "Are you sure?",
Help: "help",
}
var confirm bool
if err := survey.AskOne(prompt, &confirm); err != nil {
log.FATAL.Fatal(err)
}
if confirm {
auth.New().RemoveAdminPassword()
}
// wait for shutdown
<-shutdownDoneC()
}