ruby on rails - How to change password without current password in devise? -
i using devise
authentication
, have role
each user , allow user admin
role create new user , want admin user edit password
rest of user if forgot password. cannot able change password without current password in edit. how can allow admin user change password editing users password , save rest of values.
since update_without_password
still required current_password
update password, have have update
this:
def update # required settings form submit when password left blank if params[:user][:password].blank? params[:user].delete("password") params[:user].delete("password_confirmation") end @user = user.find(current_user.id) if @user.update_attributes(params[:user]) set_flash_message :notice, :updated # sign in user bypassing validation in case password changed sign_in @user, :bypass => true redirect_to after_update_path_for(@user) else render "edit" end end
this example meant updating current user (including user's password), can modify fit needs.
Comments
Post a Comment