openproject-token 2.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/open_project/token.rb +32 -6
- data/lib/open_project/token/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d218d4572439ee41238271a09ad784c6a94be598e8028664d2d9ad3ac0a26115
|
4
|
+
data.tar.gz: 02adcfc7070c95e4d972a59b6df4dc812631855fcc008e6ba2fcbf9fcb6f3a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4698826acfa3110b50d0d8989148ed44025722a968f2f13d257573fe05550685480b7dacc5786ec6ee450b6704eba6b60ea70cce97e2e631bc19c0a4968c3908
|
7
|
+
data.tar.gz: 29a1fdb2b2c20ec9f0af23769e31c2ac990f490932bda21314faa26387a9d617309da6a0d2591b02bb7f411a4784f7829d10007d77e30baff0e2183575558e7c
|
data/lib/open_project/token.rb
CHANGED
@@ -155,13 +155,8 @@ module OpenProject
|
|
155
155
|
|
156
156
|
def load_attributes(attributes)
|
157
157
|
attributes = Hash[attributes.map { |k, v| [k.to_s, v] }]
|
158
|
-
version = attributes["version"].then { |v| v && Gem::Version.new(v) } || current_gem_version
|
159
158
|
|
160
|
-
|
161
|
-
raise ArgumentError, "Version is too new"
|
162
|
-
end
|
163
|
-
|
164
|
-
@version = version.to_s
|
159
|
+
@version = read_version attributes
|
165
160
|
@subscriber = attributes["subscriber"]
|
166
161
|
@mail = attributes["mail"]
|
167
162
|
@company = attributes["company"]
|
@@ -184,6 +179,37 @@ module OpenProject
|
|
184
179
|
end
|
185
180
|
end
|
186
181
|
|
182
|
+
##
|
183
|
+
# Reads the version from the given attributes hash.
|
184
|
+
# Besides the usual values it allows for a special value `-1`.
|
185
|
+
# This is then results in the version being `nil` specifically rather than
|
186
|
+
# the current gem version by default.
|
187
|
+
#
|
188
|
+
# This way the generated token will get what ever version the importing party
|
189
|
+
# has. This is important due to a bug in openproject-token 1.x where any version
|
190
|
+
# other than `nil` (or the integer literal 1) results in a "Version is too new" error.
|
191
|
+
# This affects all OpenProject installations with a version older than 10.6
|
192
|
+
# which will run into internal server errors trying to activate their Enterprise
|
193
|
+
# tokens due to this.
|
194
|
+
#
|
195
|
+
# Generating tokens with version `-1` prevents that.
|
196
|
+
#
|
197
|
+
# @param attr [Hash] Parsed token attributes.
|
198
|
+
def read_version(attr)
|
199
|
+
value = attr["version"]
|
200
|
+
version = nil
|
201
|
+
|
202
|
+
if value.to_s != "-1"
|
203
|
+
version = value.then { |v| v && Gem::Version.new(v) } || current_gem_version
|
204
|
+
|
205
|
+
if version > current_gem_version
|
206
|
+
raise ArgumentError, "Version is too new"
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
version
|
211
|
+
end
|
212
|
+
|
187
213
|
def date_attribute_keys
|
188
214
|
%w(starts_at issued_at expires_at notify_admins_at notify_users_at block_changes_at)
|
189
215
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openproject-token
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenProject GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.0.
|
87
|
+
rubygems_version: 3.0.3
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: OpenProject EE token reader
|