def view_user(payload, id): if str(payload['sub']) != str(id): return 'Forbidden', 403 user = Users.query.get_or_404(id) return user_schema.dump(user), 200
def register(): user = user_schema.load(request.json) db.session.add(user) db.session.commit() return user_schema.dump(user), 201
def patch_user(payload, id): user = Users.query.get_or_404(id) user = user_schema.load(data=request.json, instance=user, partial=True) db.session.add(user) db.session.commit() return user_schema.dump(user), 200
def list_users(payload): users = Users.query.all() return jsonify(user_schema.dump(users, many=True)), 200
def user(payload): user = Users.query.get_or_404(payload['sub']) return user_schema.dump(user), 200