mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
The pinned core dated from April, before sdk stopped being a separate module, so the build resolved sdk packages from the old module and core packages from the new one. Dropping the separate requirement is what makes the two agree again. Most of the diff is renames that came with that: the tenant accessors gained a ByTenant suffix, GetDb now returns one database and GetAllDb the map, and casbin moved to v3. The change that matters is four call sites moving from GetMemoryQueue to GetQueuePrefix. GetMemoryQueue returns a queue fixed at construction, so the login log, the operate log and the api check ran in process no matter what the settings file selected — a second instance saw none of it. GetQueuePrefix returns whatever the configuration built, which is the point of being able to configure a queue at all. Verified against core at main: build and vet clean. The two file_store failures are unchanged from before this branch; they need cloud credentials.
19 lines
531 B
Go
19 lines
531 B
Go
package global
|
|
|
|
import (
|
|
"github.com/casbin/casbin/v3"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-admin-team/go-admin-core/sdk"
|
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
|
)
|
|
|
|
func LoadPolicy(c *gin.Context) (*casbin.SyncedEnforcer, error) {
|
|
log := api.GetRequestLogger(c)
|
|
if err := sdk.Runtime.GetCasbinByTenant(c.Request.Host).LoadPolicy(); err == nil {
|
|
return sdk.Runtime.GetCasbinByTenant(c.Request.Host), err
|
|
} else {
|
|
log.Errorf("casbin rbac_model or policy init error, %s ", err.Error())
|
|
return nil, err
|
|
}
|
|
}
|