简体   繁体   中英

How do you change ActiveAdmin password?

I got ActiveAdmin running with admin@example.com//password, but I want to change these credentials. Anyone know how to change them?

Best way to do this would be to change it from the rails console :

    admin = AdminUser.find_by_email("admin@domain.com")
    admin.password = "newPassword"
    admin.save

When you install ActiveAdmin using the generator, you'll find a migration called {timestamp}_devise_create_admin_users.rb in your db/migrate folder.

Find and change this line to whatever you want:

AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')

Keep in mind though, that this is just the seed password, and is being exposed as plaintext. What you might want to do is set up the Devise controllers to have a password change action. Check out the wiki and the Railscast for help.

Add this at app/admin/admin_users.rb will enable change password for edit admin user.

ActiveAdmin.register AdminUser do
  index do
    column :email
    column :current_sign_in_at
    column :last_sign_in_at
    column :sign_in_count
    default_actions
  end

  form do |f|
    f.inputs "Admin Details" do
      f.input :email
      f.input :password
    end
    f.buttons
  end  
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM