Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add a hint why we still do the `reject` and use before_save to ensure extraction

Klaus Zanders16f4338eb082
diff --git a/app/models/enterprise_token.rb b/app/models/enterprise_token.rb
index e92d44607f2..49978f30c96 100644
--- a/app/models/enterprise_token.rb
+++ b/app/models/enterprise_token.rb
@@ -96,6 +96,8 @@ class EnterpriseToken < ApplicationRecord
end
def set_active_tokens
+ # although we use the `active` scope here, we still need to filter out expired tokens
+ # as not all token validity period is extracted into the DB
EnterpriseToken
.active
.order(Arel.sql("created_at DESC"))
@@ -122,7 +124,7 @@ class EnterpriseToken < ApplicationRecord
validate :valid_token_object
validate :valid_domain
- before_validation :extract_validity_from_token
+ before_save :extract_validity_from_token
before_save :clear_current_tokens_cache
before_destroy :clear_current_tokens_cache