ActiveAdmin: how to leave user password unchanged?

active admin routes
active admin override update

I am using ActiveAdmin as my administration backend in my rails app. Basically, I have an admin_user and a user model.

When I create a new user from an admin account, I specify an email and a password, that is ok.

Let's say I then want to modify the user's email but not the password... it seems this cannot be done as the password field cannot be blank when updating a user.

Is there a configuration somewhere that would consider that the password is unchanged is the fields (password and password_confirmation) are left blank while updating a user?

Devise provides an update_without_password method that you can use when updating a user if no password is entered. Using that method, you can customize the update method in your ActiveAdmin users controller.

 def update
   @user = User.find(params[:id])
   if params[:user][:password].blank?
     @user.update_without_password(params[:user])
   else
     @user.update_attributes(params[:user])
   end
   if @user.errors.blank?
     redirect_to admin_users_path, :notice => "User updated successfully."
   else
     render :edit
   end
 end

The Devise Wiki has more information about this method if your interested.

Edit user without password in active admin (Example), A protip by jandudulski about ruby, rails, activeadmin, active_admin, and active admin. ActiveAdmin: how to leave user password unchanged? I uses ActiveAdmin as my administration backend in my rails app. Basically, I have a admin_user and a user model. When I create a new user from an admin account, I specify an email and a password, that is ok.

You don't really need to mess at all with Devise's registration controller, you can just ignore empty password fields inside ActiveAdmin's resource controller:

ActiveAdmin.register User do
  controller do

    def update
      model = :user

      if params[model][:password].blank?
        %w(password password_confirmation).each { |p| params[model].delete(p) }
      end

      super
    end
  end
end

如何保持用戶密碼不變?, I uses ActiveAdmin as my administration backend in my rails app. would consider that the password is unchanged is the fields (password and� la Devise fournit un update_without_password méthode que vous pouvez utiliser lors de la mise à jour d'un utilisateur si aucun mot de passe n'est entré. En utilisant cette méthode, vous pouvez personnaliser la méthode de mise à jour dans votre contrôleur utilisateur ActiveAdmin.

You need to evaluate password and password_confirmation in the if statement, to apply the validations on "password_confirmation", eg for my case:

#app/admin/user.rb
controller do
  def update
    if params[:user][:password].blank? && params[:user][:password_confirmation].blank?
      params[:user].delete("password")
      params[:user].delete("password_confirmation")
    end
    super
  end
end


#app/model/user.rb
validates :name, :email, presence: true
validates :password, :password_confirmation, presence: true, on: :create
validates :password, confirmation: true

This allows me to validate password presence only when I create a new user and update without changing his password.

This work for me, I hope this is helpful.

I hope this is helpful.

ActiveAdmin:如何保持用户密码不变?, ActiveAdmin:如何保持用户密码不变? ActiveAdmin: how to leave user password unchanged? 来源: link 标签: ruby-on-rails activeadmin 更新时间: 2020-03-27� For example you try to set uid of 3000 and in that case the solution will be to edit the /etc/pam.d/common-password and change the line: password [success=3 default=ignore] pam_krb5.so minimum_uid=1000 to password [success=3 default=ignore] pam_krb5.so minimum_uid=3000 save it and retry to create the user. Reply

You can validate the password only on create because bcrypt when updating will still validate password presence.

class User
   validate :password, :password_confirmation, presence: true, on: :create 
end

In my opinion this is much simpler while causing no risk, and allows you to use a single partial form for create and update routes with an if statement showing/not showing password input field like so:

<%= form_for(user, url: users_path) do |form| %>
<%= form.label 'Name' %><br>
<%= form.text_field :name%><br>

<%= form.label 'email' %><br>
<%= form.text_field :email%><br>

<%= form.label 'Password' %><br>
<%= form.password_field :password%><br>

**<% if form.object.new_record? %>**
    <%= form.label 'password_confirmation' %><br>
    <%= form.password_field :password_confirmation%><br>
**<% end %>**

<%= form.submit (form.object.new_record? ? 'create' : 'update')  %>

Keep AdminUser logged in after updating own password, ActiveAdmin: how to leave user password unchanged? 发表于 2013-03-08 10:50 :37. 活跃于 2019-06-04 05:54:37. 查看8288 次. ruby-on-rails activeadmin� ActiveAdmin offers the datepicker input, which uses the jQuery UI datepicker. The datepicker input accepts any of the options available to the standard jQueryUI Datepicker. The datepicker input accepts any of the options available to the standard jQueryUI Datepicker.

As told in comments on the @mauriceomdea answer, the def update is missing (or at least was missing for me, henerating an error.)

Here is a more complete version that worked for me :

You don't really need to mess at all with Devise's registration controller, you can just ignore empty password fields inside ActiveAdmin's resource controller:

ActiveAdmin.register User do

  controller do  
    def update
      model = :user

      if params[model][:password].blank?
        %w(password password_confirmation).each { |p| params[model].delete(p) }
      end

      super
    end
  end
end

hope this helps someone.

ruby-on-rails - ActiveAdmin:如何保持用户密码不变?, This command disallows the blank username/enable password login. However , if you enter a username and password at the login screen (instead of leaving the The per-group server limit in single mode remains unchanged at 16. 192.68. 125.60 Server port: 1645 Server status: ACTIVE (admin� $ sudo passwd <user> If you remember the root password, connect as root and change the user password over there. $ su - $ passwd <user> Conclusion. With this tutorial, you learnt how to change user password on Debian 10 Buster. Another method to authenticate on a server is to use SSH keys.

Cisco ASA Series Command Reference, A - H Commands, Certain ACLI aspects, such as login and password change prompts, change behavior for licenses acquired prior to ECZ7.5.0 remain unchanged. Use done, exit and verify-config to complete password policy. With an active Admin Security license, local login to the Oracle ESBC is restricted to the two previously. In the User Accounts window that appears, make sure the “Users must enter a user name and password to enter this computer” option is checked. Select the local account for which you want to change the username and click on the Properties button. In the General tab, type in the new username for the account then click OK.

[PDF] Oracle� Enterprise Session Border Controller, Django's built-in User model and Auth system is solid. _db) return user def create_staffuser(self, email, password): I have also tried deleting the database but there is no change in the error message. Choices are: active, admin, blog_posts, etc" when i want to implement password reset feature. If an account has a secondary password and you change its primary password without specifying RETAIN CURRENT PASSWORD, the secondary password remains unchanged. For more information about use of dual passwords, see Section 6.2.15, “Password Management”. SET PASSWORD permits these auth_option syntaxes: = ' auth_string '

How to Create a Custom Django User Model | Post, ActiveRAID, mRAID and ActiveAdmin are trademarks of Active Storage, Inc. All --password <password> Specify the account authentication <password> host password stats array event identify peerpower time battery fc info quit Items whose values are unchanged from their default values are suppressed by default . Create a New Super User and Password. By default, the administrator – or super user – is called “pi,” and the password is “raspberry.” Obviously, this is very insecure as it means that anybody with malicious intentions who has physical (or network) access to the machine can run rampant.

Comments
  • are you using devise for authentication ?
  • what does it seems mean? do you get validation errors, or what?
  • Yes, I use devise. "It seems" means I did not find the way to do that as the password field cannot be left blank.
  • Yes, and here is another way to do that stackoverflow.com/a/11676957/633742
  • Elegant! Thanks for sharing.
  • Where can i find this file? is that ok to put it in config/initializers/rails_admin.rb ?
  • @JoelCDoyle This belongs into the Active Admin registration for Model, that would be in app/admin/model.rb
  • @YuanHe This belongs into the Active Admin registration for Model, that would be in app/admin/model.rb
  • I think the def update clause is missing... With that it's working perfectly. Thanks!