summaryrefslogtreecommitdiff
path: root/app/models/grafana_integration.rb
diff options
context:
space:
mode:
authorGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2022-07-28 13:33:09 +0000
committerGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2022-07-28 13:33:09 +0000
commit328ff31ff9e6147e4fb883aaee113001da150b9e (patch)
treee1c4c45aa86e7d3f3da88030b892764fff3bc0ff /app/models/grafana_integration.rb
parent4dc46d5b97305108c1b635baa4241a2ce04a7ed0 (diff)
parentf415ebdb978c4eb976d07664219c788918120d59 (diff)
downloadgitlab-ce-15-0-stable.tar.gz
Merge remote-tracking branch 'dev/15-0-stable' into 15-0-stable15-0-stable
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