Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 22:02:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 22:02:34 +0300
commit9b60052467242bbc071bcb0f74b7437fb3dfc870 (patch)
treef6426a3d6b62ad0e33be45bcdef6ae6bae4d34b4 /app/models/grafana_integration.rb
parent1ff28a8d8d370efef8bbac2da1edb85b758d4643 (diff)
Add latest changes from gitlab-org/security/gitlab@15-2-stable-ee
Diffstat (limited to 'app/models/grafana_integration.rb')
-rw-r--r--app/models/grafana_integration.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/grafana_integration.rb b/app/models/grafana_integration.rb
index 00213732fee..0358e37c58b 100644
--- a/app/models/grafana_integration.rb
+++ b/app/models/grafana_integration.rb
@@ -18,6 +18,8 @@ class GrafanaIntegration < ApplicationRecord
validates :enabled, inclusion: { in: [true, false] }
+ before_validation :reset_token
+
scope :enabled, -> { where(enabled: true) }
def client
@@ -36,6 +38,12 @@ class GrafanaIntegration < ApplicationRecord
private
+ def reset_token
+ if grafana_url_changed? && !encrypted_token_changed?
+ self.token = nil
+ end
+ end
+
def token
decrypt(:token, encrypted_token)
end