Open sobolevn opened 7 years ago
I have a user model looks like this
class UserModel(db.Model):
__tablename__ = 'b_users'
ID = db.Column(db.Integer, primary_key=True)
user_login = db.Column(db.String(120), nullable=False)
user_pass = db.Column(db.String(120), nullable=False)
user_nicename = db.Column(db.String(120), nullable=False)
user_email = db.Column(db.String(120), nullable=False)
user_url = db.Column(db.String(120), nullable=False)
user_registered = db.Column(db.String(120), nullable=False)
user_activation_key = db.Column(db.String(120), nullable=False)
user_status = db.Column(db.Integer, nullable=False)
display_name = db.Column(db.String(120), nullable=False)
instead of id I have ID in the object so I get
identity = getattr(identity, 'id') or identity['id'] AttributeError: 'UserModel' object has no attribute 'id'
Is there any work around to use custom id field in identity object ?
I have just created a class instead of a dict
to store my id
as a property.
I'm also getting this error. I'm using namedtuple as a workaround
I would also like to use another property name, since id
is a Python built-in function.
When passing
{'id': 'someId'}
into the_default_jwt_payload_handler
it raises an exception.The problem is in this expression:
identity = getattr(identity, 'id') or identity['id']
https://github.com/mattupstate/flask-jwt/blob/master/flask_jwt/__init__.py#L53It must be:
identity = getattr(identity, 'id', None) or identity['id']