pallets-eco / flask-jwt

JWT (JSON Web Tokens) for Flask applications
MIT License
564 stars 177 forks source link

Specify all handlers using decorators instead of app config values? #14

Closed sloria closed 10 years ago

sloria commented 10 years ago

There are currently two different ways to specify handlers:

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.

sloria commented 10 years ago

P.S. I would be glad to implement this if the maintainers believe this is a good idea.

mattupstate commented 10 years ago

@sloria I agree. I'm not so sure the configuration options are necessary.