From e9cb37122e207c7aecae2737b1f4047848579eff Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Sun, 6 Aug 2023 23:02:22 +0800 Subject: [PATCH] chore(cmd): change come output for admin command --- cmd/admin.go | 6 +++--- cmd/user.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/admin.go b/cmd/admin.go index 123e4030..931a5d36 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -15,7 +15,7 @@ import ( var PasswordCmd = &cobra.Command{ Use: "admin", Aliases: []string{"password"}, - Short: "Show admin user's info", + Short: "Show admin user's info and some operations about admin user's password", Run: func(cmd *cobra.Command, args []string) { Init() admin, err := op.GetAdmin() @@ -24,8 +24,8 @@ var PasswordCmd = &cobra.Command{ } else { utils.Log.Infof("Admin user's username: %s", admin.Username) utils.Log.Infof("The password can only be output at the first startup, and then stored as a hash value, which cannot be reversed") - utils.Log.Infof("You can reset the password by running 'alist password random' to generate a random password") - utils.Log.Infof("You can also set the password by running 'alist password set NEW_PASSWORD' to set a new password") + utils.Log.Infof("You can reset the password with a random string by running [alist admin random]") + utils.Log.Infof("You can also set a new password by running [alist admin set NEW_PASSWORD]") } }, } diff --git a/cmd/user.go b/cmd/user.go index 6f7b6edb..72cee5fa 100644 --- a/cmd/user.go +++ b/cmd/user.go @@ -22,7 +22,7 @@ func DelAdminCacheOnline() { } func DelUserCacheOnline(username string) { - client := resty.New().SetTimeout(3 * time.Second).SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify}) + client := resty.New().SetTimeout(1 * time.Second).SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify}) token := setting.GetStr(conf.Token) port := conf.Conf.Scheme.HttpPort u := fmt.Sprintf("http://localhost:%d/api/admin/user/del_cache", port) @@ -35,18 +35,18 @@ func DelUserCacheOnline(username string) { } res, err := client.R().SetHeader("Authorization", token).SetQueryParam("username", username).Post(u) if err != nil { - utils.Log.Errorf("[del_user_cache] del cache error: %+v", err) + utils.Log.Warnf("[del_user_cache_online] failed: %+v", err) return } if res.StatusCode() != 200 { - utils.Log.Errorf("[del_user_cache] del cache error: %+v", res.String()) + utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String()) return } code := utils.Json.Get(res.Body(), "code").ToInt() msg := utils.Json.Get(res.Body(), "message").ToString() if code != 200 { - utils.Log.Errorf("[del_user_cache] del cache error: %s", msg) + utils.Log.Errorf("[del_user_cache_online] error: %s", msg) return } - utils.Log.Debugf("[del_user_cache] del user [%s] cache success", username) + utils.Log.Debugf("[del_user_cache_online] del user [%s] cache success", username) }