openproject-token 5.6.0 → 6.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 +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77fc561da569bc057220c91166f038cd49f8e645d5b9dde533aceb1c80bce8ea
|
4
|
+
data.tar.gz: c9c2a688b6bf1d1f9ab2547e8b19ce42c45e1dc7f0f7500210a99be3d767786f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d992f97a309f26e11cba8cb5e85fb739f5a31d3efd5278e05c967033ca29cf400c7d8cbb49875ff952f359328c312310a6d842aed5c7526d7be27bfc5077d1e
|
7
|
+
data.tar.gz: 3d752d3adafa60f6c6af059e5b06ffa1cc0a955e72b55d77440d4e3fac443b1a72b48e0420eaa0cfb0acdec9c52eb242b41988cb437eeaf6eba7f1dc7fb979d7
|
data/lib/open_project/token.rb
CHANGED
@@ -58,7 +58,8 @@ module OpenProject
|
|
58
58
|
include ActiveModel::Validations
|
59
59
|
|
60
60
|
attr_reader :version, :plan
|
61
|
-
attr_accessor :subscriber, :mail, :company, :domain, :
|
61
|
+
attr_accessor :subscriber, :mail, :company, :domain, :validate_domain,
|
62
|
+
:starts_at, :issued_at, :expires_at, :reprieve_days, :notify_admins_at,
|
62
63
|
:notify_users_at, :block_changes_at, :restrictions, :features
|
63
64
|
|
64
65
|
validates_presence_of :subscriber
|
@@ -74,6 +75,8 @@ 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
|
+
|
77
80
|
validates_each :restrictions, allow_nil: true do |record, attr, value|
|
78
81
|
record.errors.add attr, :invalid if !value.is_a?(Hash)
|
79
82
|
end
|
@@ -154,6 +157,8 @@ module OpenProject
|
|
154
157
|
|
155
158
|
# tokens with no version or a version lower than 2.0 don't have the attributes company or domain
|
156
159
|
def validate_domain?
|
160
|
+
return validate_domain unless validate_domain.nil?
|
161
|
+
|
157
162
|
version && Gem::Version.new(version) >= domain_required_from_version
|
158
163
|
end
|
159
164
|
|
@@ -183,6 +188,7 @@ module OpenProject
|
|
183
188
|
hash["mail"] = mail
|
184
189
|
hash["company"] = company
|
185
190
|
hash["domain"] = domain
|
191
|
+
hash["validate_domain"] = validate_domain
|
186
192
|
hash["plan"] = plan
|
187
193
|
|
188
194
|
hash["issued_at"] = issued_at
|
@@ -226,6 +232,7 @@ module OpenProject
|
|
226
232
|
@mail = attributes["mail"]
|
227
233
|
@company = attributes["company"]
|
228
234
|
@domain = attributes["domain"]
|
235
|
+
@validate_domain = attributes["validate_domain"]
|
229
236
|
|
230
237
|
date_attribute_keys.each do |attr|
|
231
238
|
value = attributes[attr]
|
@@ -326,5 +333,13 @@ module OpenProject
|
|
326
333
|
def apply_default_reprieve?(version)
|
327
334
|
Gem::Version.new(version) < Gem::Version.new("2.2.0")
|
328
335
|
end
|
336
|
+
|
337
|
+
# We want to ensure an expires_at is set
|
338
|
+
# when there is no domain present
|
339
|
+
def expires_at_set_when_domain_opted_out
|
340
|
+
if validate_domain == false && expires_at.nil?
|
341
|
+
errors.add(:expires_at, "must be present when domain is opted out")
|
342
|
+
end
|
343
|
+
end
|
329
344
|
end
|
330
345
|
end
|