def post(self): try: address_schema.load(request.json) except ValidationError as err: return jsonify(err.messages), 500 username = get_jwt_identity() claims = get_jwt_claims() print(claims) user_id = User.query.filter(User.username == username).first().id street_name = request.json['streetName'] city_id = request.json['cityId'] value = predict_sqli(street_name) xss_value = predict_xss(street_name) new_product = Address(street_name, city_id) new_sqli = Sqli(value, user_id, False, street_name) new_xss = Xss(xss_value, user_id, False, street_name) db.session.add(new_sqli) db.session.add(new_xss) db.session.add(new_product) value = predict_sqli(str(city_id)) new_sqli = Sqli(value, user_id, False, str(city_id)) #db.session.add(new_sqli) db.session.add(new_xss) db.session.commit() return address_schema.jsonify({'data': new_product})
def put(self, id): try: city_schema.load(request.json) except ValidationError as err: return jsonify(err.messages), 500 city = City.query.get(id) name = request.json['name'] country_id = request.json['countryId'] city.name = name city.country_id = country_id city.updated_on = db.func.now() username = get_jwt_identity() user_id = User.query.filter(User.username == username).first().id value = predict_sqli(name) xss_value = predict_xss(name) new_sqli = Sqli(value, user_id, False, name) new_xss = Xss(xss_value, user_id, False, name) db.session.add(new_sqli) db.session.add(new_xss) value = predict_sqli(str(country_id)) new_sqli = Sqli(value, user_id, False, str(country_id)) db.session.commit() return city_schema.jsonify({'data': city})
def post(self): try: city_schema.load(request.json) except ValidationError as err: print(err.messages) return jsonify(err.messages), 500 name = request.json['name'] country_id = request.json['countryId'] username = get_jwt_identity() user_id = User.query.filter(User.username == username).first().id value = predict_sqli(name) xss_value = predict_xss(name) new_xss = Xss(xss_value, user_id, False, name) new_product = City(name, country_id) new_sqli = Sqli(value, user_id, False, name) db.session.add(new_xss) db.session.add(new_sqli) db.session.add(new_product) value = predict_sqli(str(country_id)) new_sqli = Sqli(value, user_id, False, str(country_id)) db.session.add(new_sqli) db.session.commit() return city_schema.jsonify({'data': new_product})
def put(self, id): try: address_schema.load(request.json) except ValidationError as err: return jsonify(err.messages), 500 address = Address.query.get(id) street_name = request.json['streetName'] city_id = request.json['cityId'] address.street_name = street_name address.city_id = city_id address.updated_on = db.func.now() username = get_jwt_identity() user_id = User.query.filter(User.username == username).first().id value = predict_sqli(street_name) new_sqli = Sqli(value, user_id, False, street_name) xss_value = predict_xss(street_name) new_xss = Xss(xss_value, user_id, False, street_name) db.session.add(new_xss) db.session.add(new_sqli) value = predict_sqli(str(city_id)) #new_sqli = Sqli(value, user_id, False, str(city_id)) #db.session.add(new_sqli) db.session.commit() return address_schema.jsonify({'data': address})
def post(self): try: department_schema.load(request.json) except ValidationError as err: return jsonify(err.messages), 500 name = request.json['name'] username = get_jwt_identity() user_id = User.query.filter(User.username == username).first().id value = predict_sqli(name) xss_value = predict_xss(name) new_product = Department(name) db.session.add(new_product) new_sqli = Sqli(value, user_id, False, name) new_xss = Xss(xss_value, user_id, False, name) db.session.add(new_xss) db.session.add(new_sqli) db.session.commit() return department_schema.jsonify({'data': new_product})
def put(self, id): try: role_schema.load(request.json) except ValidationError as err: return jsonify(err.messages), 500 role = Role.query.get(id) name = request.json['name'] role.name = name role.updated_on = db.func.now() username = get_jwt_identity() user_id = User.query.filter(User.username == username).first().id value = predict_sqli(name) xss_value = predict_xss(name) new_sqli = Sqli(value, user_id, False, name) new_xss = Xss(xss_value, user_id, False, name) db.session.add(new_sqli) db.session.commit() return role_schema.jsonify({'data': role})