Commit 1e75c7db authored by Lin Jen-Shin's avatar Lin Jen-Shin

Reset Jenkins password if username was left blank

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/22430
parent b200d112
......@@ -24,7 +24,7 @@ class JenkinsService < CiService
before_update :reset_password
validates :username,
presence: true,
if: ->(service) { service.activated? && service.password.present? }
if: ->(service) { service.activated? && service.password_touched? }
default_value_for :push_events, true
default_value_for :merge_requests_events, false
......@@ -34,7 +34,7 @@ class JenkinsService < CiService
def reset_password
# don't reset the password if a new one is provided
if jenkins_url_changed? && !password_touched?
if (jenkins_url_changed? || username.blank?) && !password_touched?
self.password = nil
end
end
......
......@@ -13,15 +13,16 @@
- else
= form.label name, title, class: "control-label"
.col-sm-10
- if type == 'text'
- case type
- when 'text'
= form.text_field name, class: "form-control", placeholder: placeholder
- elsif type == 'textarea'
- when 'textarea'
= form.text_area name, rows: 5, class: "form-control", placeholder: placeholder
- elsif type == 'checkbox'
- when 'checkbox'
= form.check_box name
- elsif type == 'select'
- when 'select'
= form.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" }
- elsif type == 'password'
- when 'password'
= form.password_field name, autocomplete: "new-password", class: 'form-control'
- if help
%span.help-block= help
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment