def subscription_post(): license = flask.request.json['license'] license = license.lower().replace('begin license', '').replace('end license', '') license = re.sub(r'[\W_]+', '', license) try: response = utils.request.get( 'https://app.pritunl.com/subscription', json_data={ 'license': license, 'version': settings.local.version_int, }, ) except httplib.HTTPException: return utils.jsonify( { 'error': SUBSCRIPTION_SERVER_ERROR, 'error_msg': SUBSCRIPTION_SERVER_ERROR_MSG, }, 500) data = response.json() if response.status_code != 200: return utils.jsonify(data, response.status_code) subscription.update_license(license) return utils.jsonify(subscription.dict())
def subscription_post(): license = flask.request.json['license'] license = license.lower().replace('begin license', '').replace( 'end license', '') license = re.sub(r'[\W_]+', '', license) try: response = utils.request.get( 'https://app.pritunl.com/subscription', json_data={ 'license': license, 'version': settings.local.version_int, }, ) except httplib.HTTPException: return utils.jsonify({ 'error': SUBSCRIPTION_SERVER_ERROR, 'error_msg': SUBSCRIPTION_SERVER_ERROR_MSG, }, 500) data = response.json() if response.status_code != 200: return utils.jsonify(data, response.status_code) subscription.update_license(license) return utils.jsonify(subscription.dict())
def subscription_post(): # if settings.app.demo_mode: # return utils.demo_blocked() # license = flask.request.json['license'] # license = license.lower().replace('begin license', '').replace( # 'end license', '') # license = re.sub(r'[\W_]+', '', license) # try: # url = 'https://app.pritunl.com/subscription' # if settings.app.dedicated: # url = settings.app.dedicated + '/subscription' # response = requests.get( # url, # json={ # 'license': license, # 'version': settings.local.version_int, # }, # ) # except httplib.HTTPException: # return utils.jsonify({ # 'error': SUBSCRIPTION_SERVER_ERROR, # 'error_msg': SUBSCRIPTION_SERVER_ERROR_MSG, # }, 500) # data = response.json() # if response.status_code != 200: # return utils.jsonify(data, response.status_code) license = { 'active': True, 'status': 'active', 'plan': 'enterprise', 'quantity': 1, 'amount': 250, 'period_end': math.floor(time.time() / 1000) + 2592000, 'trial_end': math.floor(time.time() / 1000) + 2592000, 'cancel_at_period_end': False, 'balance': 250, 'url_key': True } try: subscription.update_license(license) except LicenseInvalid: return utils.jsonify( { 'error': LICENSE_INVALID, 'error_msg': LICENSE_INVALID_MSG, }, 500) return utils.jsonify(subscription.dict())
def subscription_post(): if settings.app.demo_mode: return utils.demo_blocked() license = flask.request.json['license'] license = license.lower().replace('begin license', '').replace('end license', '') license = re.sub(r'[\W_]+', '', license) try: url = 'https://app.pritunl.com/subscription' if settings.app.dedicated: url = settings.app.dedicated + '/subscription' response = requests.get( url, json={ 'license': license, 'version': settings.local.version_int, }, ) except http.client.HTTPException: return utils.jsonify( { 'error': SUBSCRIPTION_SERVER_ERROR, 'error_msg': SUBSCRIPTION_SERVER_ERROR_MSG, }, 500) data = response.json() if response.status_code != 200: return utils.jsonify(data, response.status_code) try: subscription.update_license(license) except LicenseInvalid: return utils.jsonify( { 'error': LICENSE_INVALID, 'error_msg': LICENSE_INVALID_MSG, }, 500) return utils.jsonify(subscription.dict())
def subscription_delete(): subscription.update_license(None) return utils.jsonify({})
def subscription_delete(): if settings.app.demo_mode: return utils.demo_blocked() subscription.update_license(None) return utils.jsonify({})