Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/cmd/cancel2FA.go
1541 views
1
/*
2
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3
*/
4
package cmd
5
6
import (
7
"github.com/alist-org/alist/v3/internal/op"
8
"github.com/alist-org/alist/v3/pkg/utils"
9
"github.com/spf13/cobra"
10
)
11
12
// Cancel2FACmd represents the delete2fa command
13
var Cancel2FACmd = &cobra.Command{
14
Use: "cancel2fa",
15
Short: "Delete 2FA of admin user",
16
Run: func(cmd *cobra.Command, args []string) {
17
Init()
18
defer Release()
19
admin, err := op.GetAdmin()
20
if err != nil {
21
utils.Log.Errorf("failed to get admin user: %+v", err)
22
} else {
23
err := op.Cancel2FAByUser(admin)
24
if err != nil {
25
utils.Log.Errorf("failed to cancel 2FA: %+v", err)
26
} else {
27
utils.Log.Info("2FA canceled")
28
DelAdminCacheOnline()
29
}
30
}
31
},
32
}
33
34
func init() {
35
RootCmd.AddCommand(Cancel2FACmd)
36
37
// Here you will define your flags and configuration settings.
38
39
// Cobra supports Persistent Flags which will work for this command
40
// and all subcommands, e.g.:
41
// cancel2FACmd.PersistentFlags().String("foo", "", "A help for foo")
42
43
// Cobra supports local flags which will only run when this command
44
// is called directly, e.g.:
45
// cancel2FACmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
46
}
47
48