[PATCH] BZ859998 disable certain fields from editing if in ldap mode

Matt Wagner matt.wagner at redhat.com
Mon Oct 1 18:09:58 UTC 2012


On Fri, Sep 28, 2012 at 03:49:44PM -0400, tzumainn at redhat.com wrote:
> From: Tzu-Mainn Chen <tzumainn at redhat.com>
> 
> ---
>  src/app/controllers/users_controller.rb |    1 +
>  src/app/views/users/_form.html.haml     |   12 ++++++------
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/app/controllers/users_controller.rb b/src/app/controllers/users_controller.rb
> index d26028d..4a2868f 100644
> --- a/src/app/controllers/users_controller.rb
> +++ b/src/app/controllers/users_controller.rb
> @@ -97,6 +97,7 @@ class UsersController < ApplicationController
>      @user = params[:id] ? User.find(params[:id]) : current_user
>      require_privilege(Privilege::MODIFY, User) unless @user == current_user
>      @title = t'users.edit.edit_user'
> +    @ldap_user = (SETTINGS_CONFIG[:auth][:strategy] == "ldap")
>    end
>  
>    def update
> diff --git a/src/app/views/users/_form.html.haml b/src/app/views/users/_form.html.haml
> index 859d920..abbb89a 100644
> --- a/src/app/views/users/_form.html.haml
> +++ b/src/app/views/users/_form.html.haml
> @@ -5,28 +5,28 @@
>    .field
>      = form.label :first_name
>      .input
> -      = form.text_field :first_name, :class =>"check_change"
> +      = form.text_field :first_name, :class =>"check_change", :disabled => @ldap_user
>    .field
>      = form.label :last_name
>      .input
> -      = form.text_field :last_name, :class =>"check_change"
> +      = form.text_field :last_name, :class =>"check_change", :disabled => @ldap_user
>    .field
>      = form.label :email, t(:email), :required => true
>      .input
> -      = form.text_field :email, :class =>"check_change"
> +      = form.text_field :email, :class =>"check_change", :disabled => @ldap_user
>  %fieldset
>    .field
>      = form.label :username, t(:choose_name), :required => true
>      .input
> -      = form.text_field :username, :class => "check_change"
> +      = form.text_field :username, :class => "check_change", :disabled => @ldap_user
>    .field
>      = form.label :password, form.object.new_record? ? t(:choose_password) : t(:change_password), :required => form.object.new_record?
>      .input
> -      = form.password_field :password
> +      = form.password_field :password, :disabled => @ldap_user
>    .field
>      = form.label :password_confirmation, t(:confirm_password), :required => form.object.new_record?
>      .input
> -      = form.password_field :password_confirmation
> +      = form.password_field :password_confirmation, :disabled => @ldap_user
>  
>  - if check_privilege(Privilege::MODIFY, User)
>    %fieldset
> -- 
> 1.7.6.5

NACK, sorry.

This does what was asked, but what was asked was wrong. O:-)

Beyond disabling this in the HTML, we need to get either the controller
or the model itself to enforce this. Otherwise, if I use Firebug to pull
the disabled="disabled" bit out of the code, Conductor merrily follows
along and makes the change. It shouldn't.

-- Matt



More information about the aeolus-devel mailing list