openproject-token 2.0 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5da90cc05359f099b94484c379973b4c4464b8f9ef7f6d20bdefba2b4fc61537
4
- data.tar.gz: 5f87461bbf02ecf0d8c5663b4dba13ea9c511dbd807d8c3e15e4adfe5c040f57
3
+ metadata.gz: d622e466da4e5bf9dab90d1ee1fcfac8757ce2a24fdc19a9c4b4be954081eaa1
4
+ data.tar.gz: 7ddbec23cf11fb83e1177abf33a942418e009f45567c0015c56fb20b9cea1225
5
5
  SHA512:
6
- metadata.gz: dd82c0f1815535f7e568d969a1c4e469beaf4d5470014c59496c12e2cd82edf0b9c6e6d9267cfa4b97ef9b6408a737f41fb1d8ae3cdb70c7353ae29f4e7cb940
7
- data.tar.gz: ec350f3838ec36b45fb6d0671bac492abd0bf7b5975ced83f2c430b6148274e34d93907525830aa4c5dc44fc2e2182f4092d7bc818d11bfdcd906a77a5411eda
6
+ metadata.gz: 87d2219c37f2574e9c7651241e2c49af4f4928b7b84278bc1f92f97c8651142e414a68bdc3e2ce79e57b78df58b82d0c1b6fe6c2719b8889ae1374a5eadd29d3
7
+ data.tar.gz: 4505d7dca7305c46cd76a7afa3435615f78413d89f60ed28f566c65acb0376fec0bc2adc95c43af09d4f3a73f42656fc6bd6ebbdbd3d08ae728ca31d3932c0d2
@@ -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
- if version > current_gem_version
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.include?("version") ? attr["version"] : current_gem_version.to_s
200
+ version = nil
201
+
202
+ if value.present? && value.to_s != "-1"
203
+ version = Gem::Version.new value
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
@@ -1,5 +1,5 @@
1
1
  module OpenProject
2
2
  class Token
3
- VERSION = "2.0"
3
+ VERSION = "2.1.3"
4
4
  end
5
5
  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: '2.0'
4
+ version: 2.1.3
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-05-15 00:00:00.000000000 Z
11
+ date: 2020-06-30 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.1
87
+ rubygems_version: 3.0.3
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: OpenProject EE token reader