Skip to content

Commit

Permalink
Merge pull request #128 from jiamo/master
Browse files Browse the repository at this point in the history
make blueprint name configurable
  • Loading branch information
ahopkins committed Aug 17, 2018
2 parents 7888f9a + ee80455 commit de3d6eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions sanic_jwt/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"strict_slashes": False,
"url_prefix": "/auth",
"user_id": "user_id",
"blueprint_name": "auth_bp",
"verify_exp": True
}

Expand Down
21 changes: 10 additions & 11 deletions sanic_jwt/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ def __init__(self, instance, app=None, **kwargs):
setattr(self, class_name, value)

app = self.__get_app(instance, app=app)
bp = self.__get_bp(instance)

self.app = app
self.bp = bp
self.kwargs = kwargs
self.instance = instance
self.config = None
self.bp = None

self.__check_deprecated()
self.__check_classes()
self.__load_configuration()
self.__initialize_bp()
self.__load_responses()
self.__add_class_views()
self.__add_endpoints()
Expand Down Expand Up @@ -290,17 +290,16 @@ def __get_app(instance, app=None):

raise exceptions.InitializationFailure

@staticmethod
def __get_bp(instance):
if isinstance(instance, Sanic):
return Blueprint("auth_bp")
def __initialize_bp(self):
if isinstance(self.instance, Sanic):
bp_name = self.config.blueprint_name()
self.bp = Blueprint(bp_name)

elif isinstance(instance, Blueprint):
return instance
elif isinstance(self.instance, Blueprint):
self.bp = self.instance

# I think this will never get here because `__get_app` get's called
# first and does the same check
raise exceptions.InitializationFailure # noqa see line above
else:
raise exceptions.InitializationFailure # noqa see line above

def protected(self, *args, **kwargs):
args = list(args)
Expand Down

0 comments on commit de3d6eb

Please sign in to comment.