Skip to content

Commit 8b6c1f5

Browse files
author
Josh Friend
committed
Fix renamed handler method names
Fixes pallets-eco#65 See also pallets-eco#64
1 parent c270841 commit 8b6c1f5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

flask_jwt/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def identify(payload):
271271
self.identity_callback = callback
272272
return callback
273273

274-
def jwt_error_handler(self, callback):
274+
def error_handler(self, callback):
275275
"""Specifies the error handler function. Example::
276276
277277
@jwt.error_handler
@@ -314,15 +314,15 @@ def request_handler(self, callback):
314314
self.request_callback = callback
315315
return callback
316316

317-
def jwt_encode_handler(self, callback):
317+
def encode_handler(self, callback):
318318
"""Specifies the encoding handler function. This function receives a payload and signs it.
319319
320320
:param callable callback: the encoding handler function
321321
"""
322322
self.jwt_encode_callback = callback
323323
return callback
324324

325-
def jwt_decode_handler(self, callback):
325+
def decode_handler(self, callback):
326326
"""Specifies the decoding handler function. This function receives a
327327
signed payload and decodes it.
328328
@@ -331,7 +331,7 @@ def jwt_decode_handler(self, callback):
331331
self.jwt_decode_callback = callback
332332
return callback
333333

334-
def jwt_payload_handler(self, callback):
334+
def payload_handler(self, callback):
335335
"""Specifies the JWT payload handler function. This function receives the return value from
336336
the ``identity_handler`` function
337337
@@ -346,17 +346,17 @@ def make_payload(identity):
346346
self.jwt_payload_callback = callback
347347
return callback
348348

349-
def jwt_headers_handler(self, callback):
349+
def headers_handler(self, callback):
350350
"""Specifies the JWT header handler function. This function receives the return value from
351351
the ``identity_handler`` function.
352352
353353
Example::
354354
355-
@jwt.payload_handler
356-
def make_payload(identity):
355+
@jwt.headers_handler
356+
def make_headers(identity):
357357
return {'user_id': identity.id}
358358
359-
:param callable callback: the payload handler function
359+
:param callable callback: the header handler function
360360
"""
361361
self.jwt_headers_callback = callback
362362
return callback

tests/test_jwt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def load_user(payload):
182182

183183

184184
def test_custom_error_handler(client, jwt):
185-
@jwt.jwt_error_handler
185+
@jwt.error_handler
186186
def error_handler(e):
187187
return "custom"
188188

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

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

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

226-
@jwt.jwt_decode_handler
226+
@jwt.decode_handler
227227
def decode_data(token):
228228
return {'user_id': user.id}
229229

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

245-
@jwt.jwt_payload_handler
245+
@jwt.payload_handler
246246
def make_payload(u):
247247
iat = datetime.utcnow()
248248
exp = iat + timedelta(seconds=60)

0 commit comments

Comments
 (0)