Skip to content

Commit

Permalink
fix: Added checks in init_with_model_and_adapter in CoreEnforcer
Browse files Browse the repository at this point in the history
Signed-off-by: divyagar <divyagarg2601@gmail.com>
  • Loading branch information
divyagar committed Apr 1, 2021
1 parent 5ed07b2 commit 1c55727
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions casbin/core_enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from casbin.effect import DefaultEffector, Effector
from casbin.model import Model, FunctionMap
from casbin.persist import Adapter
from casbin.persist.adapters import FileAdapter
from casbin.rbac import default_role_manager
from casbin.util import generate_g_function, SimpleEval, util
Expand Down Expand Up @@ -51,6 +52,10 @@ def init_with_adapter(self, model_path, adapter=None):

def init_with_model_and_adapter(self, m, adapter=None):
"""initializes an enforcer with a model and a database adapter."""

if not isinstance(m, Model) or adapter is not None and not isinstance(adapter, Adapter):
raise RuntimeError("Invalid parameters for enforcer.")

self.adapter = adapter

self.model = m
Expand Down

0 comments on commit 1c55727

Please sign in to comment.