Skip to content

Commit e480515

Browse files
Refactor license evaluation logic and improve error handling for missing license
1 parent cf975c7 commit e480515

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

react_on_rails_pro/lib/react_on_rails_pro/license_validator.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
module ReactOnRailsPro
66
class LicenseValidator
7+
# Grace period: 1 month (in seconds)
8+
GRACE_PERIOD_SECONDS = 30 * 24 * 60 * 60
9+
710
class << self
811
# Validates the license and returns the license data
912
# Caches the result after first validation
@@ -45,8 +48,8 @@ def reset!
4548
# @return [Boolean] true if plan is not "paid"
4649
def evaluation?
4750
data = validated_license_data!
48-
plan = data["plan"]
49-
plan != "paid"
51+
plan = data["plan"].to_s
52+
plan != "paid" && !plan.start_with?("paid_")
5053
end
5154

5255
# Returns remaining grace period days if license is expired but in grace period
@@ -61,9 +64,6 @@ def grace_days_remaining
6164

6265
private
6366

64-
# Grace period: 1 month (in seconds)
65-
GRACE_PERIOD_SECONDS = 30 * 24 * 60 * 60
66-
6767
# Validates the license data and raises if invalid
6868
# Logs info/errors and handles grace period logic
6969
# @param license [Hash] The decoded license data
@@ -160,10 +160,10 @@ def load_license_string
160160
config_path = Rails.root.join("config", "react_on_rails_pro_license.key")
161161
return File.read(config_path).strip if config_path.exist?
162162

163-
@validation_error = "No license found. Please set REACT_ON_RAILS_PRO_LICENSE environment variable " \
164-
"or create #{config_path} file. " \
165-
"Get a FREE evaluation license at https://shakacode.com/react-on-rails-pro"
166-
handle_invalid_license(@validation_error)
163+
error_msg = "No license found. Please set REACT_ON_RAILS_PRO_LICENSE environment variable " \
164+
"or create #{config_path} file. " \
165+
"Get a FREE evaluation license at https://shakacode.com/react-on-rails-pro"
166+
handle_invalid_license(error_msg)
167167
end
168168

169169
def public_key

0 commit comments

Comments
 (0)