()
return jsonify({'msg': '密码修改成功', 'status': 1})
修改密码
修改密码
修改密码
def change_password():
    """ 修改密码 """
    data = request.json
    old_password = data.get('oldPassword')
    new_password = data.get('newPassword')
    sure_password = data.get('surePassword')
    # user_id = data.get('id')
    if not current_user.verify_password(old_password):
        return jsonify({'msg': '旧密码错误', 'status': 0})
    if not new_password:
        return jsonify({'msg': '新密码不能为空', 'status': 0})
    if new_password != sure_password:
        return jsonify({'msg': '新密码和确认密码不一致', 'status': 0})
    # old_data = User.query.filter_by(id=user_id).first()
    current_user.password = new_password
    db.session.commit()
    return jsonify({'msg': '密码修改成功', 'status': 1})
def change_password ( ) : data = request . json old_password = data . get ( 'oldPassword' ) new_password = data . get ( 'newPassword' ) sure_password = data . get ( 'surePassword' ) # user_id = data.get('id') if not current_user . verify_password ( old_password ) : return jsonify ( { 'msg' : '旧密码错误', 'status' : 0}) if not new_password : return jsonify ( { 'msg' : '新密码不能为空', 'status': 0} ) if new_password != sure_password : return jsonify ( { 'msg' : '新密码和确认密码不一致', 'status': 0}) # old_data = User.query.filter_by(id=user_id).first() current_user . password = new_password db . session . commit ( ) return jsonify ( { 'msg' : '密码修改成功', 'status':  1 )