openproject-token 5.6.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/open_project/token/version.rb +1 -1
- data/lib/open_project/token.rb +33 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6ac0004df7e78a0a684a2f03f3ea6ef7b2c17412fc3733715b184975d70cfed
|
4
|
+
data.tar.gz: 0405bb6c40b5644554552743acac9e7af7882cc7a8a489ed3e6b98f01db29bca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a438c178966e9a0036c411848d183cba6479607dede79b80802b4f01e0631375c7f08035bf63c6fa06e265b166ef3942fc84fb10f13f7bcc4e9ece4e5eff59c
|
7
|
+
data.tar.gz: 00d0bbb67969aff8a5a45b9be94232f314ecd461d221561ef5164a546016b514fd6ab4b080e54a8fa4dcf969110206169f521d0d47952dafe85e1f1d9f36fce3
|
data/lib/open_project/token.rb
CHANGED
@@ -58,8 +58,9 @@ module OpenProject
|
|
58
58
|
include ActiveModel::Validations
|
59
59
|
|
60
60
|
attr_reader :version, :plan
|
61
|
-
attr_accessor :subscriber, :mail, :company, :domain, :
|
62
|
-
:
|
61
|
+
attr_accessor :subscriber, :mail, :company, :domain, :validate_domain,
|
62
|
+
:starts_at, :issued_at, :expires_at, :reprieve_days, :notify_admins_at,
|
63
|
+
:notify_users_at, :block_changes_at, :trial, :restrictions, :features
|
63
64
|
|
64
65
|
validates_presence_of :subscriber
|
65
66
|
validates_presence_of :mail
|
@@ -74,6 +75,9 @@ module OpenProject
|
|
74
75
|
record.errors.add attr, "is not a date" if !value.is_a?(Date)
|
75
76
|
end
|
76
77
|
|
78
|
+
validate :expires_at_set_when_domain_opted_out
|
79
|
+
validate :expires_at_set_when_trial
|
80
|
+
|
77
81
|
validates_each :restrictions, allow_nil: true do |record, attr, value|
|
78
82
|
record.errors.add attr, :invalid if !value.is_a?(Hash)
|
79
83
|
end
|
@@ -98,6 +102,10 @@ module OpenProject
|
|
98
102
|
block_changes_at
|
99
103
|
end
|
100
104
|
|
105
|
+
def trial?
|
106
|
+
trial
|
107
|
+
end
|
108
|
+
|
101
109
|
def has_feature?(name)
|
102
110
|
available_features.include?(name.to_sym)
|
103
111
|
end
|
@@ -154,6 +162,8 @@ module OpenProject
|
|
154
162
|
|
155
163
|
# tokens with no version or a version lower than 2.0 don't have the attributes company or domain
|
156
164
|
def validate_domain?
|
165
|
+
return validate_domain unless validate_domain.nil?
|
166
|
+
|
157
167
|
version && Gem::Version.new(version) >= domain_required_from_version
|
158
168
|
end
|
159
169
|
|
@@ -183,6 +193,7 @@ module OpenProject
|
|
183
193
|
hash["mail"] = mail
|
184
194
|
hash["company"] = company
|
185
195
|
hash["domain"] = domain
|
196
|
+
hash["validate_domain"] = validate_domain
|
186
197
|
hash["plan"] = plan
|
187
198
|
|
188
199
|
hash["issued_at"] = issued_at
|
@@ -190,6 +201,8 @@ module OpenProject
|
|
190
201
|
hash["expires_at"] = expires_at if will_expire?
|
191
202
|
hash["reprieve_days"] = reprieve_days if will_expire?
|
192
203
|
|
204
|
+
hash["trial"] = trial
|
205
|
+
|
193
206
|
hash["notify_admins_at"] = notify_admins_at if will_notify_admins?
|
194
207
|
hash["notify_users_at"] = notify_users_at if will_notify_users?
|
195
208
|
hash["block_changes_at"] = block_changes_at if will_block_changes?
|
@@ -226,6 +239,7 @@ module OpenProject
|
|
226
239
|
@mail = attributes["mail"]
|
227
240
|
@company = attributes["company"]
|
228
241
|
@domain = attributes["domain"]
|
242
|
+
@validate_domain = attributes["validate_domain"]
|
229
243
|
|
230
244
|
date_attribute_keys.each do |attr|
|
231
245
|
value = attributes[attr]
|
@@ -265,6 +279,8 @@ module OpenProject
|
|
265
279
|
end
|
266
280
|
|
267
281
|
@plan = attributes["plan"].presence&.to_sym || OpenProject::Token::DEFAULT_PLAN
|
282
|
+
|
283
|
+
@trial = !!attributes["trial"]
|
268
284
|
end
|
269
285
|
|
270
286
|
##
|
@@ -326,5 +342,20 @@ module OpenProject
|
|
326
342
|
def apply_default_reprieve?(version)
|
327
343
|
Gem::Version.new(version) < Gem::Version.new("2.2.0")
|
328
344
|
end
|
345
|
+
|
346
|
+
# We want to ensure an expires_at is set
|
347
|
+
# when there is no domain present
|
348
|
+
def expires_at_set_when_domain_opted_out
|
349
|
+
if validate_domain == false && expires_at.nil?
|
350
|
+
errors.add(:expires_at, "must be present when domain is opted out")
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
# We want to ensure an expires_at is set when the token is a trial token
|
355
|
+
def expires_at_set_when_trial
|
356
|
+
if trial? && expires_at.nil?
|
357
|
+
errors.add(:expires_at, "must be present for a trial")
|
358
|
+
end
|
359
|
+
end
|
329
360
|
end
|
330
361
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openproject-token
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenProject GmbH
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activemodel
|