Skip to content

Commit

Permalink
fix: password reset issue and handle missing config file (#1290)
Browse files Browse the repository at this point in the history
* fix: password reset issue and handle missing config file

* Add option to reset password with custom config file
  • Loading branch information
jeessy2 authored Oct 25, 2024
1 parent 2c4d8a8 commit 92354d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
// 设置跳过证书验证
Expand Down
1 change: 1 addition & 0 deletions util/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}

Expand Down

0 comments on commit 92354d6

Please sign in to comment.