API: user - minor refactor
This commit is contained in:
parent
2f0c952ecc
commit
436476c55d
@ -152,19 +152,7 @@ def get_user_status(user_id):
|
|||||||
user = User.query.filter_by(id=user_id).first()
|
user = User.query.filter_by(id=user_id).first()
|
||||||
response_object = {
|
response_object = {
|
||||||
'status': 'success',
|
'status': 'success',
|
||||||
'data': {
|
'data': user.serialize()
|
||||||
'id': user.id,
|
|
||||||
'username': user.username,
|
|
||||||
'email': user.email,
|
|
||||||
'created_at': user.created_at,
|
|
||||||
'admin': user.admin,
|
|
||||||
'first_name': user.first_name,
|
|
||||||
'last_name': user.last_name,
|
|
||||||
'bio': user.bio,
|
|
||||||
'location': user.location,
|
|
||||||
'birth_date': user.birth_date,
|
|
||||||
'picture': True if user.picture else False,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return jsonify(response_object), 200
|
return jsonify(response_object), 200
|
||||||
|
|
||||||
|
@ -76,3 +76,18 @@ class User(db.Model):
|
|||||||
return 'Signature expired. Please log in again.'
|
return 'Signature expired. Please log in again.'
|
||||||
except jwt.InvalidTokenError:
|
except jwt.InvalidTokenError:
|
||||||
return 'Invalid token. Please log in again.'
|
return 'Invalid token. Please log in again.'
|
||||||
|
|
||||||
|
def serialize(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'username': self.username,
|
||||||
|
'email': self.email,
|
||||||
|
'created_at': self.created_at,
|
||||||
|
'admin': self.admin,
|
||||||
|
'first_name': self.first_name,
|
||||||
|
'last_name': self.last_name,
|
||||||
|
'bio': self.bio,
|
||||||
|
'location': self.location,
|
||||||
|
'birth_date': self.birth_date,
|
||||||
|
'picture': self.picture is not None
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user