Ejemplo n.º 1
0
def user_update(id):
    user = User.query.get(id)
    username = request.json['username']
    email = request.json['email']

    user.email = email
    user.username = username

    db.session.commit()
    return user_schema.jsonify(user)
Ejemplo n.º 2
0
def register():
    name = request.json['username']
    email = request.json['email']
    password = request.json['password']

    new_user = User(name, email, password)

    try:
        db.session.add(new_user)
        db.session.commit()
    except:
        return 'Username or Email was registed!'

    return user_schema.jsonify(new_user)
Ejemplo n.º 3
0
def login():
    name = request.json['username']
    password = request.json['password']

    user = User.query.filter_by(user_name=name).first()

    if not user:
        return "This account have been not registed!!"

    if user.is_deleted:
        return 'This user was delete, please contact the admin!'

    if user.user_password == password:
        return user_schema.jsonify(user)

    return 'Wrong password!'
Ejemplo n.º 4
0
def user_delete(id):
    user = User.query.get(id)
    db.session.delete(user)
    db.session.commit()

    return user_schema.jsonify(user)
Ejemplo n.º 5
0
def user_detail(id):
    user = User.query.get(id)
    return user_schema.jsonify(user)