Skip to content
Permalink
Browse files

Remove license key constraint

  • Loading branch information...
joebuhlig committed Mar 12, 2018
1 parent f121d2c commit d008ce2ef386174000de98b7bb28acc385494a43
@@ -1,5 +1,5 @@
{{#conditional-loading-spinner condition=model.loading}}
<div class="customize league admin">
<div class="admin-customize league">
<div class="admin-container">
<div class='content-list span6'>
<h3>{{i18n 'admin.league.titles.levels'}}</h3>
@@ -39,7 +39,6 @@ en:
delete_confirm: "Delete this League level?"
no_levels: "Add some levels for your users."
no_level_selected: "No level selected."
unlicensed_message: 'This section requires a valid license key. <a href="https://discourseleague.com/premium" target="_blank">Get your key here</a> and enter it into the <a href="/admin/site_settings/category/all_results?filter=league%20license%20key">plugin settings here</a>.'
league:
title: "Discourse League"
member_exists: "Looks like you're already a member of the group that this membership level grants. If you feel this is a mistake, please contact one of our admins."
@@ -101,8 +100,6 @@ en:
USD: "$"

league:
admin:
not_licensed_message: "Your Discourse League license key doesn't allow you to create this membership level."
errors:
first_name: "First Name"
last_name: "Last Name"
@@ -1,7 +1,6 @@
en:
site_settings:
league_enabled: 'Enable the League. All settings are found here at the bottom of the settings category list. All League group and page setup is found at <a href="/admin/plugins/league">/admin/plugins/league</a>.'
league_license_key: 'Enter your license key to unlock premium features. Get a license key at <a href="https://discourseleague.com/premium">discourseleague.com/premium</a>.'
league_go_live: "The League runs in TEST mode until you enable this option. Turn this on when you're ready to go live."
league_contact_user: "The user account that will be used to send private messages."
league_currency: "The currency to use for payments. BE CERTAIN THAT GATEWAY DEFAULTS MATCH THIS CURRENCY."
@@ -2,21 +2,6 @@ plugins:
league_enabled:
default: true
client: true
league_license_key:
default: ""
client: false
league_licensed_bronze:
default: false
client: true
hidden: true
league_licensed_silver:
default: false
client: true
hidden: true
league_licensed_gold:
default: false
client: true
hidden: true

discourse_league:
league_go_live:
@@ -19,40 +19,6 @@ class ::CurrentUserSerializer
end

module ::Jobs
class LeagueConfirmValidKey < Jobs::Scheduled
every 1.days

def execute(args)
validate_url = "https://discourseleague.com/licenses/validate?base_url=" + Discourse.base_url + "&id=23264&key=" + SiteSetting.league_license_key
request = Net::HTTP.get(URI.parse(validate_url))
result = JSON.parse(request)

if result["enabled"]
if result["license_id"] == 23264
SiteSetting.league_licensed_bronze = true
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
elsif result["license_id"] == 35080
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = true
SiteSetting.league_licensed_gold = false
elsif result["license_id"] == 39973
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = true
else
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
end
else
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
end
end

end

class SubscriptionCanceled < Jobs::Base
def execute(args)
@@ -201,54 +167,5 @@ def execute(args)

end

end
end

require 'open-uri'
require 'net/http'

DiscourseEvent.on(:site_setting_saved) do |site_setting|
if site_setting.name.to_s == "league_license_key" && site_setting.value_changed?

if site_setting.value.empty?
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
else
validate_url = "https://discourseleague.com/licenses/validate?base_url=" + Discourse.base_url + "&id=23264&key=" + site_setting.value
request = Net::HTTP.get(URI.parse(validate_url))
result = JSON.parse(request)

if result["errors"]
raise Discourse::InvalidParameters.new(
'Sorry. That key is invalid.'
)
end

if result["enabled"]
if result["license_id"] == 23264
SiteSetting.league_licensed_bronze = true
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
elsif result["license_id"] ==35080
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = true
SiteSetting.league_licensed_gold = false
elsif result["license_id"] == 39973
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = true
else
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
end
else
SiteSetting.league_licensed_bronze = false
SiteSetting.league_licensed_silver = false
SiteSetting.league_licensed_gold = false
end
end

end
end

This file was deleted.

0 comments on commit d008ce2

Please sign in to comment.
You can’t perform that action at this time.