Esempio n. 1
0
def login():
    mobile = request.form.get('mobile')
    passwd = request.form.get('passwd')
    user = UserInfo().query.filter_by(mobile=mobile).first()
    if user and user.check_pwd(passwd):
        session['user_id'] = user.id
        return jsonify(res=2, nick_name=user.nick_name, avatar=user.avatar)
    return jsonify(res=1)
Esempio n. 2
0
def user_pass_info():
    if request.method == 'GET':
        return render_template('news/user_pass_info.html')
    passwd_old = request.form.get('passwd_old')
    passwd_new = request.form.get('passwd_new')
    user_id = session.get('user_id')
    user = UserInfo().query.get(user_id)
    if user.check_pwd(passwd_old):
        user.password = passwd_new
        db.session.commit()
        del session['user_id']
        return jsonify(res=1)
    return jsonify(res=2)