Skip to content

Commit

Permalink
Fix renamed handler method names
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Friend committed May 20, 2016
1 parent c270841 commit 8b6c1f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions flask_jwt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def identify(payload):
self.identity_callback = callback
return callback

def jwt_error_handler(self, callback):
def error_handler(self, callback):
"""Specifies the error handler function. Example::
@jwt.error_handler
Expand Down Expand Up @@ -314,15 +314,15 @@ def request_handler(self, callback):
self.request_callback = callback
return callback

def jwt_encode_handler(self, callback):
def encode_handler(self, callback):
"""Specifies the encoding handler function. This function receives a payload and signs it.
:param callable callback: the encoding handler function
"""
self.jwt_encode_callback = callback
return callback

def jwt_decode_handler(self, callback):
def decode_handler(self, callback):
"""Specifies the decoding handler function. This function receives a
signed payload and decodes it.
Expand All @@ -331,7 +331,7 @@ def jwt_decode_handler(self, callback):
self.jwt_decode_callback = callback
return callback

def jwt_payload_handler(self, callback):
def payload_handler(self, callback):
"""Specifies the JWT payload handler function. This function receives the return value from
the ``identity_handler`` function
Expand All @@ -346,17 +346,17 @@ def make_payload(identity):
self.jwt_payload_callback = callback
return callback

def jwt_headers_handler(self, callback):
def headers_handler(self, callback):
"""Specifies the JWT header handler function. This function receives the return value from
the ``identity_handler`` function.
Example::
@jwt.payload_handler
def make_payload(identity):
@jwt.headers_handler
def make_headers(identity):
return {'user_id': identity.id}
:param callable callback: the payload handler function
:param callable callback: the header handler function
"""
self.jwt_headers_callback = callback
return callback
8 changes: 4 additions & 4 deletions tests/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def load_user(payload):


def test_custom_error_handler(client, jwt):
@jwt.jwt_error_handler
@jwt.error_handler
def error_handler(e):
return "custom"

Expand All @@ -205,7 +205,7 @@ def test_custom_encode_handler(client, jwt, user, app):
secret = app.config['JWT_SECRET_KEY']
alg = 'HS256'

@jwt.jwt_encode_handler
@jwt.encode_handler
def encode_data(identity):
return _jwt.encode({'hello': 'world'}, secret, algorithm=alg)

Expand All @@ -223,7 +223,7 @@ def test_custom_decode_handler(client, user, jwt):
def load_user(payload):
assert payload == {'user_id': user.id}

@jwt.jwt_decode_handler
@jwt.decode_handler
def decode_data(token):
return {'user_id': user.id}

Expand All @@ -242,7 +242,7 @@ def load_user(payload):
if payload['id'] == user.id:
return user

@jwt.jwt_payload_handler
@jwt.payload_handler
def make_payload(u):
iat = datetime.utcnow()
exp = iat + timedelta(seconds=60)
Expand Down

0 comments on commit 8b6c1f5

Please sign in to comment.