52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
//go:build plus
|
|
|
|
package plus
|
|
|
|
import (
|
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
|
"github.com/iwind/TeaGo/actions"
|
|
"net/http"
|
|
)
|
|
|
|
func NewHelper(component ComponentCode) *Helper {
|
|
return &Helper{component: component}
|
|
}
|
|
|
|
func NewBasicHelper() *Helper {
|
|
return NewHelper("")
|
|
}
|
|
|
|
type Helper struct {
|
|
component string
|
|
}
|
|
|
|
func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) (goNext bool) {
|
|
if !teaconst.IsPlus || !AllowComponent(this.component) {
|
|
var writer = actionPtr.Object().ResponseWriter
|
|
writer.WriteHeader(http.StatusForbidden)
|
|
writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
_, _ = writer.Write([]byte(`<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>权限错误</title>
|
|
<link rel="stylesheet" type="text/css" href="/css/semantic.min.css?v=bRafhK" media="all"/>
|
|
<style type="text/css">
|
|
div { max-width: 960px; margin: 4em auto; }
|
|
h3 { font-weight: normal; }
|
|
p { font-size: 14px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<h3>权限错误</h3>
|
|
<p>此操作需要商业版用户权限。如果你已经是商业用户,请重新访问 <a href="/settings/authority">商业版认证页</a> 以便激活权限。</p>
|
|
</div>
|
|
</body>
|
|
</html>`))
|
|
|
|
return false
|
|
}
|
|
return true
|
|
}
|