mirror of https://github.com/Xhofe/alist
chore(cmd): change come output for admin command
parent
a425392a2b
commit
e9cb37122e
|
@ -15,7 +15,7 @@ import (
|
||||||
var PasswordCmd = &cobra.Command{
|
var PasswordCmd = &cobra.Command{
|
||||||
Use: "admin",
|
Use: "admin",
|
||||||
Aliases: []string{"password"},
|
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) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
Init()
|
Init()
|
||||||
admin, err := op.GetAdmin()
|
admin, err := op.GetAdmin()
|
||||||
|
@ -24,8 +24,8 @@ var PasswordCmd = &cobra.Command{
|
||||||
} else {
|
} else {
|
||||||
utils.Log.Infof("Admin user's username: %s", admin.Username)
|
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("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 reset the password with a random string by running [alist admin random]")
|
||||||
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 also set a new password by running [alist admin set NEW_PASSWORD]")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
10
cmd/user.go
10
cmd/user.go
|
@ -22,7 +22,7 @@ func DelAdminCacheOnline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DelUserCacheOnline(username string) {
|
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)
|
token := setting.GetStr(conf.Token)
|
||||||
port := conf.Conf.Scheme.HttpPort
|
port := conf.Conf.Scheme.HttpPort
|
||||||
u := fmt.Sprintf("http://localhost:%d/api/admin/user/del_cache", port)
|
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)
|
res, err := client.R().SetHeader("Authorization", token).SetQueryParam("username", username).Post(u)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
if res.StatusCode() != 200 {
|
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
|
return
|
||||||
}
|
}
|
||||||
code := utils.Json.Get(res.Body(), "code").ToInt()
|
code := utils.Json.Get(res.Body(), "code").ToInt()
|
||||||
msg := utils.Json.Get(res.Body(), "message").ToString()
|
msg := utils.Json.Get(res.Body(), "message").ToString()
|
||||||
if code != 200 {
|
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
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue