Example #1
0
def add_user_info():
    user = User(uName=request.form.get('username'),
                gender=request.form.get('gender'),
                address=request.form.get('address'),
                tel=request.form.get('tel'))
    user.set_password(request.form.get('password'))
    db_app.session.add(user)
    db_app.session.commit()
    return jsonify({'status': 'success'})
Example #2
0
def reset_user_psw():
    offid = request.args.get('uid', type=int)
    user = User().query.filter_by(userID=offid).first()
    if user == None:
        return jsonify({'status': 'fail'})
    else:
        new_psd = ''.join(
            random.sample(string.ascii_letters + string.digits, 8))
        user.set_password(new_psd)
        db_app.session.commit()
        return jsonify({'status': 'success', 'newpsw': new_psd})
Example #3
0
def put_user_info():
    offid = request.args.get('uid', type=int)
    user = User().query.filter_by(userID=offid).first()
    if user == None:
        return jsonify({'status': 'fail'})
    else:
        user.uName = request.form.get('username')
        user.gender = request.form.get('gender')
        user.address = request.form.get('address')
        user.tel = request.form.get('tel')
        userpsd = request.form.get('password')
        if userpsd != ' ':
            user.set_password(userpsd)
        db_app.session.commit()
        return jsonify({'status': 'success'})