Exemple #1
0
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
Exemple #2
0
def register():
    user = user_schema.load(request.json)

    db.session.add(user)
    db.session.commit()

    return user_schema.dump(user), 201
Exemple #3
0
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
Exemple #4
0
def list_users(payload):
    users = Users.query.all()

    return jsonify(user_schema.dump(users, many=True)), 200
Exemple #5
0
def user(payload):
    user = Users.query.get_or_404(payload['sub'])

    return user_schema.dump(user), 200