fix: password reset issue and handle missing config file (#1290)
Some checks failed
Update Docker Hub Description / dockerHubDescription (push) Has been cancelled
test / test (amd64) (push) Has been cancelled
test / test (arm64) (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

* fix: password reset issue and handle missing config file

* Add option to reset password with custom config file
This commit is contained in:
jeessy2 2024-10-25 09:42:37 +08:00 committed by GitHub
parent 2c4d8a82f8
commit 92354d6847
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View File

@ -64,6 +64,7 @@
- 重置密码
```bash
./ddns-go -resetPassword 123456
./ddns-go -resetPassword 123456 -c /Users/name/.ddns_go_config.yaml
```
- [可选] 使用 [Homebrew](https://brew.sh) 安装 [ddns-go](https://formulae.brew.sh/formula/ddns-go)

View File

@ -94,8 +94,12 @@ func main() {
}
// 重置密码
if *newPassword != "" {
conf, _ := config.GetConfigCached()
conf.ResetPassword(*newPassword)
conf, err := config.GetConfigCached()
if err == nil {
conf.ResetPassword(*newPassword)
} else {
util.Log("配置文件 %s 不存在, 可通过-c指定配置文件", *configFilePath)
}
return
}
// 设置跳过证书验证

View File

@ -113,6 +113,7 @@ func init() {
message.SetString(language.English, "登录失败次数过多,请等待 %d 分钟后再试", "Too many login failures, please try again after %d minutes")
message.SetString(language.English, "用户名 %s 的密码已重置成功! 请重启ddns-go", "The password of username %s has been reset successfully! Please restart ddns-go")
message.SetString(language.English, "需在 %s 之前完成用户名密码设置,请重启ddns-go", "Need to complete the username and password setting before %s, please restart ddns-go")
message.SetString(language.English, "配置文件 %s 不存在, 可通过-c指定配置文件", "Config file %s does not exist, you can specify the configuration file through -c")
}