Closed sloria closed 10 years ago
There are currently two different ways to specify handlers:
JWT_ENCODE_HANDLER
JWT_DECODE_HANDLER
JWT_PAYLOAD_HANDLER
JWT#user_handler
JWT#error_handler
Why not just have one mechanism for defining these handlers? Personally, the decorator syntax feels most natural:
@jwt.payload_handler def make_payload(user): return {'user_id': user.id } @jwt.user_handler def get_user(payload): return User.get(payload['user_id']
This makes for a more consistent and cohesive API.
P.S. I would be glad to implement this if the maintainers believe this is a good idea.
@sloria I agree. I'm not so sure the configuration options are necessary.
There are currently two different ways to specify handlers:
JWT_ENCODE_HANDLER
,JWT_DECODE_HANDLER
,JWT_PAYLOAD_HANDLER
JWT#user_handler
,JWT#error_handler
Why not just have one mechanism for defining these handlers? Personally, the decorator syntax feels most natural:
This makes for a more consistent and cohesive API.