feat: user roles (#852)

* [WIP] feat: user roles

* update

* update

* admin handler

* update

* feat: user-specific connection secret

* simplify some logics

* cleanup

* update waf

* update user api error handling

* update waf api

* fix codeql

* update waf table

* fix several problems

* add pagination for waf api

* update permission checks

* switch to runtime check

* 1

* cover?

* some changes
This commit is contained in:
UUBulb
2024-12-22 00:05:41 +08:00
committed by GitHub
parent 50ee62172f
commit 653d0cf2e9
35 changed files with 841 additions and 180 deletions

View File

@@ -13,6 +13,7 @@ import (
ddns2 "github.com/nezhahq/nezha/pkg/ddns"
"github.com/nezhahq/nezha/pkg/ddns/dummy"
"github.com/nezhahq/nezha/pkg/ddns/webhook"
"github.com/nezhahq/nezha/pkg/utils"
)
var (
@@ -24,12 +25,10 @@ var (
func initDDNS() {
DB.Find(&DDNSList)
DDNSCacheLock.Lock()
DDNSCache = make(map[uint64]*model.DDNSProfile)
for i := 0; i < len(DDNSList); i++ {
DDNSCache[DDNSList[i].ID] = DDNSList[i]
}
DDNSCacheLock.Unlock()
OnNameserverUpdate()
}
@@ -56,10 +55,7 @@ func UpdateDDNSList() {
DDNSListLock.Lock()
defer DDNSListLock.Unlock()
DDNSList = make([]*model.DDNSProfile, 0, len(DDNSCache))
for _, p := range DDNSCache {
DDNSList = append(DDNSList, p)
}
DDNSList = utils.MapValuesToSlice(DDNSCache)
slices.SortFunc(DDNSList, func(a, b *model.DDNSProfile) int {
return cmp.Compare(a.ID, b.ID)
})