2019-10-06 06:17:13 +00:00
|
|
|
from models.User import User, user_schema, users_schema
|
2019-10-07 05:51:36 +00:00
|
|
|
from flask import request, jsonify, Response, json
|
2019-10-04 22:00:47 +00:00
|
|
|
|
|
|
|
class UserEndpoint(object):
|
|
|
|
def users():
|
2019-10-07 05:51:36 +00:00
|
|
|
users = User.query.all()
|
|
|
|
response = users_schema.dumps(users)
|
2019-10-04 22:00:47 +00:00
|
|
|
return response
|
2019-10-07 05:51:36 +00:00
|
|
|
def user():
|
|
|
|
|
|
|
|
auth_header = request.headers.get('Authorization') or None
|
|
|
|
auth_token = auth_header.split(" ")[1]
|
|
|
|
user = User.decode_auth_token(auth_token) or None
|
|
|
|
response = json.dumps(user)
|
|
|
|
return response
|