Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed May 2, 2024
1 parent c67f5bb commit 3d09600
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,20 @@ func (e *Enforcer) updateFilteredPoliciesWithoutNotify(sec string, ptype string,
err error
)

if e.model[sec] == nil || e.model[sec][ptype] == nil {
return nil, fmt.Errorf("invalid sec: %s, ptype: %s", sec, ptype)
}

if e.shouldPersist() {
if oldRules, err = e.adapter.(persist.UpdatableAdapter).UpdateFilteredPolicies(sec, ptype, newRules, fieldIndex, fieldValues...); err != nil {
if err.Error() != notImplemented {
return nil, err
}
}
if e.model[sec] != nil && e.model[sec][ptype] != nil {
// For compatibility, because some adapters return oldRules containing ptype, see https://github.com/casbin/xorm-adapter/issues/49
for i, oldRule := range oldRules {
if len(oldRules[i]) == len(e.model[sec][ptype].Tokens)+1 {
oldRules[i] = oldRule[1:]
}
// For compatibility, because some adapters return oldRules containing ptype, see https://github.com/casbin/xorm-adapter/issues/49
for i, oldRule := range oldRules {
if len(oldRules[i]) == len(e.model[sec][ptype].Tokens)+1 {
oldRules[i] = oldRule[1:]
}
}
}
Expand Down

0 comments on commit 3d09600

Please sign in to comment.