Skip to content

Commit

Permalink
fixes #22174 - confirm password added for create host and hostgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Karsale committed Mar 29, 2019
1 parent d1e191e commit 0240213
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def add_host_base_params_filter(filter)
:overwrite,
:provider,
:root_pass,
:root_pass_confirmation,
:start,
:type,
:pxe_loader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def hostgroup_params_filter
filter.permit :name,
:description,
:root_pass,
:root_pass_confirmation,
:title,
:vm_defaults,
:pxe_loader,
Expand Down
1 change: 1 addition & 0 deletions app/models/host/managed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class Jail < ::Safemode::Jail
validates :architecture_id, :presence => true, :if => Proc.new {|host| host.managed}
validates :root_pass, :length => {:minimum => 8, :message => _('should be 8 characters or more')},
:presence => {:message => N_('should not be blank - consider setting a global or host group default')},
:confirmation => true,
:if => Proc.new { |host| host.managed && !host.image_build? && build? }
validates :ptable_id, :presence => {:message => N_("can't be blank unless a custom partition has been defined")},
:if => Proc.new { |host| host.managed && host.disk.empty? && !Foreman.in_rake? && !host.image_build? && host.build? }
Expand Down
2 changes: 1 addition & 1 deletion app/models/hostgroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Hostgroup < ApplicationRecord
before_destroy EnsureNotUsedBy.new(:hosts)
has_many :hostgroup_classes
has_many :puppetclasses, :through => :hostgroup_classes, :dependent => :destroy
validates :root_pass, :allow_blank => true, :length => {:minimum => 8, :message => _('should be 8 characters or more')}
validates :root_pass, :allow_blank => true, :length => {:minimum => 8, :message => _('should be 8 characters or more')}, :confirmation => true
has_many :group_parameters, :dependent => :destroy, :foreign_key => :reference_id, :inverse_of => :hostgroup
accepts_nested_attributes_for :group_parameters, :allow_destroy => true
include ParameterValidators
Expand Down
1 change: 1 addition & 0 deletions app/views/hostgroups/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<%= render "common/os_selection/initial", :item=> @hostgroup %>
<%= password_f f, :root_pass, :help_inline => _("Password must be 8 characters or more").html_safe,
:unset => action_name == "edit", :keep_value => action_name == "clone" %>
<%= password_f f, :root_pass_confirmation, :help_inline => _("Confirm Password must match Root Password").html_safe, :label => _("Confirm Password") %>
</div>

<div class="tab-pane" id="params">
Expand Down
1 change: 1 addition & 0 deletions app/views/hosts/_operating_system.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<div id='root_password'>
<%= password_f f, :root_pass, :help_inline => _("Password must be 8 characters or more"), :required => true,
:unset => action_name == "edit", :keep_value => action_name == "clone" %>
<%= password_f f, :root_pass_confirmation, :help_inline => _("Confirm Password must match Root Password").html_safe, :required => true, :label => _("Confirm Password") %>
</div>
<!-- this section is used for displaying the provisioning scripts-->
<div class="form-group">
Expand Down

0 comments on commit 0240213

Please sign in to comment.