* refactor:separate the setting method from the db package to the op package and add the cache * refactor:separate the meta method from the db package to the op package * fix:setting not load database data * refactor:separate the user method from the db package to the op package * refactor:remove user JoinPath error * fix:op package user cache * refactor:fs package list method * fix:tile virtual paths (close #2743) * Revert "refactor:remove user JoinPath error" This reverts commit 4e20daaf9e700da047000d4fd4900abbe05c3848. * clean path directly may lead to unknown behavior * fix: The path of the meta passed in must be prefix of reqPath * chore: rename all virtualPath to mountPath * fix: `getStoragesByPath` and `GetStorageVirtualFilesByPath` is_sub_path: /a/b isn't subpath of /a/bc * fix: don't save setting if hook error Co-authored-by: Noah Hsu <i@nn.ci>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
/*
|
|
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
|
*/
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/alist-org/alist/v3/internal/op"
|
|
"github.com/alist-org/alist/v3/pkg/utils"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// cancel2FACmd represents the delete2fa command
|
|
var cancel2FACmd = &cobra.Command{
|
|
Use: "cancel2fa",
|
|
Short: "Delete 2FA of admin user",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
Init()
|
|
admin, err := op.GetAdmin()
|
|
if err != nil {
|
|
utils.Log.Errorf("failed to get admin user: %+v", err)
|
|
} else {
|
|
err := op.Cancel2FAByUser(admin)
|
|
if err != nil {
|
|
utils.Log.Errorf("failed to cancel 2FA: %+v", err)
|
|
}
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(cancel2FACmd)
|
|
|
|
// Here you will define your flags and configuration settings.
|
|
|
|
// Cobra supports Persistent Flags which will work for this command
|
|
// and all subcommands, e.g.:
|
|
// cancel2FACmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
|
|
// Cobra supports local flags which will only run when this command
|
|
// is called directly, e.g.:
|
|
// cancel2FACmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
}
|