diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-10 06:07:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-10 06:07:25 +0300 |
commit | 4a6dacc8662ed65c0b83a3715e4eb05a78168db1 (patch) | |
tree | 04aced9d7d60c1213db9d5152158afe02126599f /app/services/error_tracking | |
parent | 070ac34d473978dc27ea2878ed1cf17865e24e9a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/error_tracking')
-rw-r--r-- | app/services/error_tracking/list_projects_service.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/services/error_tracking/list_projects_service.rb b/app/services/error_tracking/list_projects_service.rb index 2f23d47029c..d52306ef805 100644 --- a/app/services/error_tracking/list_projects_service.rb +++ b/app/services/error_tracking/list_projects_service.rb @@ -2,6 +2,8 @@ module ErrorTracking class ListProjectsService < ErrorTracking::BaseService + MASKED_TOKEN_REGEX = /\A\*+\z/.freeze + private def perform @@ -20,23 +22,31 @@ module ErrorTracking def project_error_tracking_setting (super || project.build_error_tracking_setting).tap do |setting| + url_changed = !setting.api_url&.start_with?(params[:api_host]) + setting.api_url = ErrorTracking::ProjectErrorTrackingSetting.build_api_url_from( api_host: params[:api_host], organization_slug: 'org', project_slug: 'proj' ) - setting.token = token(setting) + setting.token = token(setting, url_changed) setting.enabled = true end end strong_memoize_attr :project_error_tracking_setting - def token(setting) + def token(setting, url_changed) + return if url_changed && masked_token? + # Use param token if not masked, otherwise use database token - return params[:token] unless /\A\*+\z/.match?(params[:token]) + return params[:token] unless masked_token? setting.token end + + def masked_token? + MASKED_TOKEN_REGEX.match?(params[:token]) + end end end |