chore(cmd): change come output for admin command

pull/4939/head
Andy Hsu 2023-08-06 23:02:22 +08:00
parent a425392a2b
commit e9cb37122e
2 changed files with 8 additions and 8 deletions

View File

@ -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]")
}
},
}

View File

@ -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)
}