pallets-eco / flask-jwt

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

bugfix for dict based identity #63

Open pall-valmundsson opened 8 years ago

pall-valmundsson commented 8 years ago

When using a dict object to represent an identity the default jwt_encode_callback handler fails as getattr does not work with dict objects. This change sets the default value of getattr to None so the dict get part of the statement is evaluated.

The tests required a different implementation of the app fixture.

garykrige commented 8 years ago

Please merge this :+1:

davidrpmorris commented 8 years ago

:+1:

ntamas commented 8 years ago

:+1: (same as my pull request #79 - I did not notice this one).

aguegu commented 8 years ago

I have run into the same error when retrieving identity from RethinkDB, which return in dict.

I would create my own PR if I did not find this PR.

by the way, how about make it this way

identity = getattr(identity, 'id', None) or identity.get('id', None)

feel more robust

Wish it being merged soon.

eLvErDe commented 8 years ago

Hello,

I just ran into the same issue, please merge :)

Regards, Adam.

garykrige commented 8 years ago

@mattupstate this is a fairly urgent and easy bug to fix

setyongr commented 8 years ago

@mattupstate this issue still not fixed, please merge

stephane commented 8 years ago

I don't intend to maintain the fork but in the meantime, I merged several nice PRs and fixes into https://github.com/webstack/flask-jwt/commits/fork