Skip to content

Commit 293a343

Browse files
authored
fix: decode CasbinRule (#49)
When a field does not exist in the mongodb document, CasbinRule uses the last value, expecting the field to be empty
1 parent a1f441b commit 293a343

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ func (a *adapter) LoadFilteredPolicy(model model.Model, filter interface{}) erro
227227
} else {
228228
a.filtered = true
229229
}
230-
line := CasbinRule{}
231230

232231
ctx, cancel := context.WithTimeout(context.TODO(), a.timeout)
233232
defer cancel()
@@ -238,6 +237,7 @@ func (a *adapter) LoadFilteredPolicy(model model.Model, filter interface{}) erro
238237
}
239238

240239
for cursor.Next(ctx) {
240+
line := CasbinRule{}
241241
err := cursor.Decode(&line)
242242
if err != nil {
243243
return err

0 commit comments

Comments
 (0)