1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

fix: 解决网站删除密码访问后,无法关闭密码访问的问题 (#1528)

This commit is contained in:
zhengkunwang223 2023-07-04 14:40:11 +08:00 committed by GitHub
parent 24e6fe89c8
commit 6fea06729e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -1496,14 +1496,6 @@ func (w WebsiteService) UpdateAuthBasic(req request.NginxAuthUpdate) (err error)
if !fileOp.Stat(absoluteAuthPath) {
_ = fileOp.CreateFile(absoluteAuthPath)
}
defer func() {
if err != nil {
switch req.Operate {
case "create":
}
}
}()
params = append(params, dto.NginxParam{Name: "auth_basic", Params: []string{`"Authentication"`}})
params = append(params, dto.NginxParam{Name: "auth_basic_user_file", Params: []string{authPath}})
@ -1511,7 +1503,9 @@ func (w WebsiteService) UpdateAuthBasic(req request.NginxAuthUpdate) (err error)
if err != nil {
return
}
authArray = strings.Split(string(authContent), "\n")
if len(authContent) > 0 {
authArray = strings.Split(string(authContent), "\n")
}
switch req.Operate {
case "disable":
return deleteNginxConfig(constant.NginxScopeServer, params, &website)
@ -1582,6 +1576,9 @@ func (w WebsiteService) UpdateAuthBasic(req request.NginxAuthUpdate) (err error)
defer passFile.Close()
writer := bufio.NewWriter(passFile)
for _, line := range authArray {
if line == "" {
continue
}
_, err = writer.WriteString(line + "\n")
if err != nil {
return
@ -1591,6 +1588,15 @@ func (w WebsiteService) UpdateAuthBasic(req request.NginxAuthUpdate) (err error)
if err != nil {
return
}
authContent, err = fileOp.GetContent(absoluteAuthPath)
if err != nil {
return
}
if len(authContent) == 0 {
if err = deleteNginxConfig(constant.NginxScopeServer, params, &website); err != nil {
return
}
}
return
}

View File

@ -1,5 +1,5 @@
<template>
<div class="collapse">
<div class="menu-collapse">
<el-icon class="collapse-icon" :size="25" @click="menuStore.setCollapse()">
<component :is="isCollapse ? 'expand' : 'fold'"></component>
</el-icon>
@ -14,7 +14,7 @@ const isCollapse = computed((): boolean => menuStore.isCollapse);
</script>
<style scoped lang="scss">
.collapse {
.menu-collapse {
height: 48px;
border-top: 1px solid #e4e7ed;
box-sizing: border-box;

View File

@ -151,7 +151,7 @@ html.dark {
}
}
}
.collapse {
.menu-collapse {
color: var(--el-menu-text-color);
border: var(--panel-border);
}