cschiewek / devise_ldap_authenticatable

Devise Module for LDAP
MIT License
594 stars 359 forks source link

Cannot Edit user (undefined method `update_with_password') #266

Open valentin2105 opened 3 years ago

valentin2105 commented 3 years ago

Hello,

I have followed the wiki, https://github.com/cschiewek/devise_ldap_authenticatable/wiki Everything run fine, I can reach my user, email, uid, and it create the record in the DB if doesn't exist.

I dont want my app to be able to change password in my LDAP, so I setup config.ldap_update_password = false.

My issue is when I edit my user (/users/edit), I have some custom field that I setup (which work previously on classic devise with DB),

-> I don't change email or password, -> and when I confirm my actual password (or not) I got this error :

NoMethodError (undefined method `update_with_password' for #<User:0x00007fa42eb14cf0>
Did you mean?  updated_at_was):

I have to add this to make a workaround, (model/user.rb) :

  def update_with_password(params)
    @current_password = params[:current_password]
    @new_password = params[:password]
    update_attributes(params)
  end

And I had to delete all passwords field from the devise/registrations/edit.html.erb to be able the edit users. I hope it can help people.

Thanks for this libs !