Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 启用外网访问, 必须输入登录用户名/密码 #390

Merged
merged 2 commits into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions web/save.go
Expand Up @@ -14,8 +14,8 @@ func Save(writer http.ResponseWriter, request *http.Request) {

conf, _ := config.GetConfigCache()

idNew := request.FormValue("DnsID")
secretNew := request.FormValue("DnsSecret")
idNew := strings.TrimSpace(request.FormValue("DnsID"))
secretNew := strings.TrimSpace(request.FormValue("DnsSecret"))

idHide, secretHide := getHideIDSecret(&conf)

Expand Down Expand Up @@ -51,6 +51,12 @@ func Save(writer http.ResponseWriter, request *http.Request) {
conf.NotAllowWanAccess = request.FormValue("NotAllowWanAccess") == "on"
conf.TTL = request.FormValue("TTL")

// 如启用公网访问,帐号密码不能为空
if !conf.NotAllowWanAccess && (conf.Username == "" || conf.Password == "") {
writer.Write([]byte("启用外网访问, 必须输入登录用户名/密码"))
return
}

// 保存到用户目录
err := conf.SaveConfig()

Expand Down
6 changes: 4 additions & 2 deletions web/writing.html
Expand Up @@ -31,7 +31,7 @@
<button class="btn btn-primary submit_btn" style="margin-bottom: 15px;">Save</button>

<div class="alert alert-success" style="display: none;">
<strong id="resultMsg">保存成功</strong>
<strong id="resultMsg"></strong>
</div>

<div class="portlet">
Expand Down Expand Up @@ -319,10 +319,12 @@ <h5 class="portlet__head">Webhook</h5>
success: function (result) {
$('.alert').css("display", "block");
if (result !== "ok") {
$('.alert').addClass("alert-danger")
$('.alert').addClass("alert-danger").removeClass("alert-success")
$('#resultMsg').html(result)
} else {
// ok
$('.alert').addClass("alert-success").removeClass("alert-danger")
$('#resultMsg').html("保存成功")
setTimeout(function(){
$('.alert').css("display", "none");
}, 3000)
Expand Down