package global import ( "github.com/casbin/casbin/v2" "github.com/gin-gonic/gin" "gogs.baozhida.cn/zoie/OAuth-core/api" "gogs.baozhida.cn/zoie/OAuth-core/sdk" "gogs.baozhida.cn/zoie/OAuth-core/sdk/config" ) func LoadPolicy(c *gin.Context) (*casbin.SyncedEnforcer, error) { log := api.GetRequestLogger(c) //if err := sdk.Runtime.GetCasbinKey(c.Request.Host).LoadPolicy(); err == nil { // return sdk.Runtime.GetCasbinKey(c.Request.Host), nil //} else { // log.Errorf("casbin rbac_model or policy init error, %s ", err.Error()) // return nil, err //} if err := sdk.Runtime.GetCasbinKey(config.ApplicationConfig.Host).LoadPolicy(); err == nil { return sdk.Runtime.GetCasbinKey(config.ApplicationConfig.Host), nil } else { log.Errorf("casbin rbac_model or policy init error, %s ", err.Error()) return nil, err } }