Skip to content

Commit

Permalink
add policy auto load param check
Browse files Browse the repository at this point in the history
  • Loading branch information
czyt committed Mar 1, 2023
1 parent 51c1ff1 commit 1e4d567
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/casbin/casbin/v2"
"github.com/czyt/kasbin/internal/builtinmodel"
"github.com/go-kratos/kratos/v2/middleware"
"time"
)

type contextKey string
Expand Down Expand Up @@ -42,7 +43,7 @@ func Server(opts ...Option) middleware.Middleware {
}
// add policy autoload
if o.autoLoadPolicy && o.enforcer != nil {
if !o.enforcer.IsAutoLoadingRunning() {
if !o.enforcer.IsAutoLoadingRunning() && o.autoLoadPolicyInterval > time.Duration(0) {
o.enforcer.StartAutoLoadPolicy(o.autoLoadPolicyInterval)
}
}
Expand Down

0 comments on commit 1e4d567

Please sign in to comment.