增加简单的安全设置

This commit is contained in:
GoEdgeLab
2020-11-20 18:06:54 +08:00
parent f8b6116c73
commit b764f470d9
9 changed files with 197 additions and 8 deletions

View File

@@ -1,6 +1,10 @@
package security
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
import (
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
)
type IndexAction struct {
actionutils.ParentAction
@@ -11,5 +15,35 @@ func (this *IndexAction) Init() {
}
func (this *IndexAction) RunGet(params struct{}) {
config, err := securitymanager.LoadSecurityConfig()
if err != nil {
this.ErrorPage(err)
return
}
this.Data["config"] = config
this.Show()
}
func (this *IndexAction) RunPost(params struct {
Frame string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo("修改管理界面安全设置")
config, err := securitymanager.LoadSecurityConfig()
if err != nil {
this.ErrorPage(err)
return
}
config.Frame = params.Frame
err = securitymanager.UpdateSecurityConfig(config)
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -12,7 +12,7 @@ func init() {
Helper(helpers.NewUserMustAuth()).
Helper(settingutils.NewHelper("security")).
Prefix("/settings/security").
Get("", new(IndexAction)).
GetPost("", new(IndexAction)).
EndAll()
})
}