Beispiel #1
0
def edit_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    User.query.filter_by(username=g.user.username).update(data)
    db.session.commit()
    return make_response(jsonify({'id': g.user.id}), 200)
Beispiel #2
0
def edit_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    User.query.filter_by(username = g.user.username).update(data)
    db.session.commit()
    return make_response(jsonify({'id': g.user.id}), 200)
Beispiel #3
0
def new_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    user = User(username=data.get('username'))
    user.password = data.get('password')
    db.session.add(user)
    db.session.commit()
    return make_response(jsonify({'id': user.id}), 201)
Beispiel #4
0
def new_user():
    if not request.get_json():
        return err.make_error(400, "Missing json body")

    data, errors = user_schema.load(request.json)
    if errors:
        return err.make_error(400, "Invalid json body")

    user = User(username = data.get('username'))
    user.password = data.get('password')
    db.session.add(user)
    db.session.commit()
    return make_response(jsonify({'id': user.id}), 201)